renaming to Thermion

This commit is contained in:
Nick Fisher
2024-06-15 15:05:34 +08:00
parent 1a5f573bc0
commit fe62a70e29
719 changed files with 7291 additions and 3946 deletions

BIN
examples/assets/1.glb Normal file

Binary file not shown.

BIN
examples/assets/2.glb Normal file

Binary file not shown.

BIN
examples/assets/3.glb Normal file

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 KiB

Binary file not shown.

View File

@@ -0,0 +1,755 @@
{
"accessors": [
{
"componentType": 5123,
"count": 24408,
"type": "SCALAR"
},
{
"componentType": 5126,
"count": 8468,
"type": "VEC2"
},
{
"componentType": 5126,
"count": 8468,
"type": "VEC3"
},
{
"componentType": 5126,
"count": 8468,
"type": "VEC4"
},
{
"componentType": 5126,
"count": 8468,
"type": "VEC3",
"max": [
0.131662,
0.137638986,
0.10078799
],
"min": [
-0.131333,
-0.028128,
-0.137763992
]
},
{
"componentType": 5123,
"count": 65688,
"type": "SCALAR"
},
{
"componentType": 5126,
"count": 12552,
"type": "VEC2"
},
{
"componentType": 5126,
"count": 12552,
"type": "VEC3"
},
{
"componentType": 5126,
"count": 12552,
"type": "VEC4"
},
{
"componentType": 5126,
"count": 12552,
"type": "VEC3",
"max": [
0.11722149,
0.196387976,
0.132422984
],
"min": [
-0.11722149,
-0.196387976,
-0.132422984
]
},
{
"componentType": 5123,
"count": 2208,
"type": "SCALAR"
},
{
"componentType": 5126,
"count": 436,
"type": "VEC2"
},
{
"componentType": 5126,
"count": 436,
"type": "VEC3"
},
{
"componentType": 5126,
"count": 436,
"type": "VEC4"
},
{
"componentType": 5126,
"count": 436,
"type": "VEC3",
"max": [
0.09527509,
0.114654,
-0.08429489
],
"min": [
-0.0952748954,
0.0551489964,
-0.14295499
]
},
{
"componentType": 5123,
"count": 60288,
"type": "SCALAR"
},
{
"componentType": 5126,
"count": 17186,
"type": "VEC2"
},
{
"componentType": 5126,
"count": 17186,
"type": "VEC3"
},
{
"componentType": 5126,
"count": 17186,
"type": "VEC4"
},
{
"componentType": 5126,
"count": 17186,
"type": "VEC3",
"max": [
0.1572095,
0.2716865,
0.162181988
],
"min": [
-0.1572095,
-0.2716865,
-0.162181988
]
},
{
"componentType": 5123,
"count": 131574,
"type": "SCALAR"
},
{
"componentType": 5126,
"count": 24148,
"type": "VEC2"
},
{
"componentType": 5126,
"count": 24148,
"type": "VEC3"
},
{
"componentType": 5126,
"count": 24148,
"type": "VEC4"
},
{
"componentType": 5126,
"count": 24148,
"type": "VEC3",
"max": [
0.1504075,
0.328366965,
0.173673
],
"min": [
-0.1504075,
-0.328366965,
-0.173673
]
}
],
"asset": {
"generator": "glTF Tools for Unity",
"version": "2.0"
},
"bufferViews": [
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 59806
},
{
"buffer": 0,
"byteOffset": 59808,
"byteLength": 99674
},
{
"buffer": 0,
"byteOffset": 159484,
"byteLength": 4875
},
{
"buffer": 0,
"byteOffset": 164360,
"byteLength": 133545
},
{
"buffer": 0,
"byteOffset": 297908,
"byteLength": 203914
}
],
"buffers": [
{
"name": "FlightHelmet",
"byteLength": 501824,
"uri": "FlightHelmet.bin"
}
],
"images": [
{
"name": "FlightHelmet_baseColor",
"uri": "FlightHelmet_baseColor.png"
},
{
"name": "FlightHelmet_occlusionRoughnessMetallic",
"uri": "FlightHelmet_occlusionRoughnessMetallic.png"
},
{
"name": "FlightHelmet_normal",
"uri": "FlightHelmet_normal.png"
},
{
"name": "FlightHelmet_baseColor1",
"uri": "FlightHelmet_baseColor1.png"
},
{
"name": "FlightHelmet_occlusionRoughnessMetallic1",
"uri": "FlightHelmet_occlusionRoughnessMetallic1.png"
},
{
"name": "FlightHelmet_normal1",
"uri": "FlightHelmet_normal1.png"
},
{
"name": "FlightHelmet_baseColor2",
"uri": "FlightHelmet_baseColor2.png"
},
{
"name": "FlightHelmet_occlusionRoughnessMetallic2",
"uri": "FlightHelmet_occlusionRoughnessMetallic2.png"
},
{
"name": "FlightHelmet_normal2",
"uri": "FlightHelmet_normal2.png"
},
{
"name": "FlightHelmet_baseColor3",
"uri": "FlightHelmet_baseColor3.png"
},
{
"name": "FlightHelmet_occlusionRoughnessMetallic3",
"uri": "FlightHelmet_occlusionRoughnessMetallic3.png"
},
{
"name": "FlightHelmet_normal3",
"uri": "FlightHelmet_normal3.png"
},
{
"name": "FlightHelmet_baseColor4",
"uri": "FlightHelmet_baseColor4.png"
},
{
"name": "FlightHelmet_occlusionRoughnessMetallic4",
"uri": "FlightHelmet_occlusionRoughnessMetallic4.png"
},
{
"name": "FlightHelmet_normal4",
"uri": "FlightHelmet_normal4.png"
}
],
"meshes": [
{
"primitives": [
{
"attributes": {
"TEXCOORD_0": 1,
"NORMAL": 2,
"TANGENT": 3,
"POSITION": 4
},
"indices": 0,
"material": 0,
"mode": 4,
"extensions": {
"KHR_draco_mesh_compression": {
"bufferView": 0,
"attributes": {
"TEXCOORD_0": 0,
"NORMAL": 1,
"TANGENT": 2,
"POSITION": 3
}
}
}
}
],
"name": "GlassPlastic_low"
},
{
"primitives": [
{
"attributes": {
"TEXCOORD_0": 6,
"NORMAL": 7,
"TANGENT": 8,
"POSITION": 9
},
"indices": 5,
"material": 1,
"mode": 4,
"extensions": {
"KHR_draco_mesh_compression": {
"bufferView": 1,
"attributes": {
"TEXCOORD_0": 0,
"NORMAL": 1,
"TANGENT": 2,
"POSITION": 3
}
}
}
}
],
"name": "LeatherParts_low"
},
{
"primitives": [
{
"attributes": {
"TEXCOORD_0": 11,
"NORMAL": 12,
"TANGENT": 13,
"POSITION": 14
},
"indices": 10,
"material": 2,
"mode": 4,
"extensions": {
"KHR_draco_mesh_compression": {
"bufferView": 2,
"attributes": {
"TEXCOORD_0": 0,
"NORMAL": 1,
"TANGENT": 2,
"POSITION": 3
}
}
}
}
],
"name": "Lenses_low"
},
{
"primitives": [
{
"attributes": {
"TEXCOORD_0": 16,
"NORMAL": 17,
"TANGENT": 18,
"POSITION": 19
},
"indices": 15,
"material": 3,
"mode": 4,
"extensions": {
"KHR_draco_mesh_compression": {
"bufferView": 3,
"attributes": {
"TEXCOORD_0": 0,
"NORMAL": 1,
"TANGENT": 2,
"POSITION": 3
}
}
}
}
],
"name": "MetalParts_low"
},
{
"primitives": [
{
"attributes": {
"TEXCOORD_0": 21,
"NORMAL": 22,
"TANGENT": 23,
"POSITION": 24
},
"indices": 20,
"material": 4,
"mode": 4,
"extensions": {
"KHR_draco_mesh_compression": {
"bufferView": 4,
"attributes": {
"TEXCOORD_0": 0,
"NORMAL": 1,
"TANGENT": 2,
"POSITION": 3
}
}
}
}
],
"name": "RubberWood_low"
}
],
"materials": [
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 0,
"texCoord": 0
},
"metallicRoughnessTexture": {
"index": 1,
"texCoord": 0
},
"baseColorFactor": [
1,
1,
1,
1
],
"metallicFactor": 1,
"roughnessFactor": 1
},
"normalTexture": {
"index": 2,
"texCoord": 0
},
"occlusionTexture": {
"index": 1,
"texCoord": 0
},
"name": "GlassPlasticMat",
"emissiveFactor": [
0,
0,
0
],
"alphaMode": "OPAQUE",
"doubleSided": false
},
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 3,
"texCoord": 0
},
"metallicRoughnessTexture": {
"index": 4,
"texCoord": 0
},
"baseColorFactor": [
1,
1,
1,
1
],
"metallicFactor": 1,
"roughnessFactor": 1
},
"normalTexture": {
"index": 5,
"texCoord": 0
},
"occlusionTexture": {
"index": 4,
"texCoord": 0
},
"name": "LeatherPartsMat",
"emissiveFactor": [
0,
0,
0
],
"alphaMode": "OPAQUE",
"doubleSided": false
},
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 6,
"texCoord": 0
},
"metallicRoughnessTexture": {
"index": 7,
"texCoord": 0
},
"baseColorFactor": [
1,
1,
1,
1
],
"metallicFactor": 1,
"roughnessFactor": 1
},
"normalTexture": {
"index": 8,
"texCoord": 0
},
"occlusionTexture": {
"index": 7,
"texCoord": 0
},
"alphaMode": "BLEND",
"name": "LensesMat",
"emissiveFactor": [
0,
0,
0
],
"doubleSided": false
},
{
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 9,
"texCoord": 0
},
"metallicRoughnessTexture": {
"index": 10,
"texCoord": 0
},
"baseColorFactor": [
1,
1,
1,
1
],
"metallicFactor": 1,
"roughnessFactor": 1
},
"normalTexture": {
"index": 11,
"texCoord": 0
},
"occlusionTexture": {
"index": 10,
"texCoord": 0
},
"name": "MetalPartsMat",
"emissiveFactor": [
0,
0,
0
],
"alphaMode": "OPAQUE",
"doubleSided": false
},
{
"doubleSided": true,
"pbrMetallicRoughness": {
"baseColorTexture": {
"index": 12,
"texCoord": 0
},
"metallicRoughnessTexture": {
"index": 13,
"texCoord": 0
},
"baseColorFactor": [
1,
1,
1,
1
],
"metallicFactor": 1,
"roughnessFactor": 1
},
"normalTexture": {
"index": 14,
"texCoord": 0
},
"occlusionTexture": {
"index": 13,
"texCoord": 0
},
"name": "RubberWoodMat",
"emissiveFactor": [
0,
0,
0
],
"alphaMode": "OPAQUE"
}
],
"nodes": [
{
"mesh": 0,
"name": "GlassPlastic_low"
},
{
"mesh": 1,
"translation": [
0.000434499962,
0.032592997,
0.011676996
],
"name": "LeatherParts_low",
"rotation": [
0,
0,
0,
1
],
"scale": [
1,
1,
1
]
},
{
"mesh": 2,
"name": "Lenses_low"
},
{
"mesh": 3,
"translation": [
0.0331545,
-0.1488645,
-0.0242879968
],
"name": "MetalParts_low",
"rotation": [
0,
0,
0,
1
],
"scale": [
1,
1,
1
]
},
{
"mesh": 4,
"translation": [
-0.00190849893,
-0.111985,
-0.013313001
],
"name": "RubberWood_low",
"rotation": [
0,
0,
0,
1
],
"scale": [
1,
1,
1
]
},
{
"children": [
0,
1,
2,
3,
4
],
"rotation": [
0,
1,
0,
0
],
"name": "FlightHelmet",
"translation": [
0,
0,
0
],
"scale": [
1,
1,
1
]
}
],
"scene": 0,
"scenes": [
{
"nodes": [
5
]
}
],
"textures": [
{
"source": 0
},
{
"source": 1
},
{
"source": 2
},
{
"source": 3
},
{
"source": 4
},
{
"source": 5
},
{
"source": 6
},
{
"source": 7
},
{
"source": 8
},
{
"source": 9
},
{
"source": 10
},
{
"source": 11
},
{
"source": 12
},
{
"source": 13
},
{
"source": 14
}
],
"extensionsRequired": [
"KHR_draco_mesh_compression"
],
"extensionsUsed": [
"KHR_draco_mesh_compression"
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 806 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 737 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

View File

@@ -0,0 +1,16 @@
# Flight Helmet
## Screenshot
![screenshot](screenshot/screenshot.jpg)
## License Information
Donated by Microsoft for glTF testing
[![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/)
To the extent possible under law, Microsoft has waived all copyright and related or neighboring rights to this asset.
Draco compression was done via Cesium tools on 27-03-2020 as follows.
gltf-pipeline -i FlightHelmet.gltf -o FlightHelmet.gltf -d -s --keep-unused-elements

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

View File

@@ -0,0 +1,14 @@
material {
name : SolidColor,
shadingModel : unlit,
culling : none,
featureLevel : 1,
vertexDomain: object
}
fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
material.baseColor = vec4(0.1f, 0.5f, 0.9f, 1.0f);
}
}

3
examples/dart/cli_macos/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/

View File

@@ -0,0 +1,3 @@
## 1.0.0
- Initial version.

View File

@@ -0,0 +1,2 @@
A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.

View File

@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.
include: package:lints/recommended.yaml
# Uncomment the following section to specify additional rules.
# linter:
# rules:
# - camel_case_types
# analyzer:
# exclude:
# - path/to/excluded/files/**
# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints
# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options

View File

@@ -0,0 +1 @@
../../../assets

View File

@@ -0,0 +1,46 @@
import 'dart:io';
import 'package:thermion_dart/thermion_dart/compatibility/compatibility.dart';
import 'package:thermion_dart/thermion_dart/swift/swift_bindings.g.dart';
import 'package:thermion_dart/thermion_dart/compatibility/compatibility.dart';
import 'package:thermion_dart/thermion_dart/utils/dart_resources.dart';
import 'package:ffi/ffi.dart';
import 'package:thermion_dart/thermion_dart.dart';
void main() async {
var scriptDir = File(Platform.script.toFilePath()).parent.path;
final lib = ThermionDartTexture1(
DynamicLibrary.open("$scriptDir/libthermion_swift.dylib"));
final object = ThermionDartTexture.new1(lib);
object.initWithWidth_height_(500, 500);
final resourceLoader = calloc<ResourceLoaderWrapper>(1);
var loadToOut = NativeCallable<
Void Function(Pointer<Char>,
Pointer<ResourceBuffer>)>.listener(DartResourceLoader.loadResource);
resourceLoader.ref.loadToOut = loadToOut.nativeFunction;
var freeResource = NativeCallable<Void Function(ResourceBuffer)>.listener(
DartResourceLoader.freeResource);
resourceLoader.ref.freeResource = freeResource.nativeFunction;
var viewer = FilamentViewer(resourceLoader: resourceLoader.cast<Void>());
await viewer.initialized;
await viewer.createSwapChain(500, 500);
await viewer.createRenderTarget(500, 500, object.metalTextureAddress);
await viewer.updateViewportAndCameraProjection(500, 500);
var outDir = Directory("$scriptDir/output");
if (outDir.existsSync()) {
outDir.deleteSync(recursive: true);
}
outDir.createSync();
await viewer.setRecordingOutputDirectory(outDir.path);
await viewer.setRecording(true);
await viewer.loadSkybox(
"file:///$scriptDir/assets/default_env/default_env_skybox.ktx");
await Future.delayed(Duration(milliseconds: 16));
await viewer.render();
await viewer.dispose();
}

View File

@@ -0,0 +1 @@
../../../../thermion_dart/native/lib/macos/swift/libthermion_swift.dylib

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -0,0 +1,515 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_fe_analyzer_shared:
dependency: transitive
description:
name: _fe_analyzer_shared
sha256: eaa289c9bf5327b3afda8925d6d0cd60f0103f9303974b70d54f78d863a7a4b6
url: "https://pub.dev"
source: hosted
version: "70.0.0"
_macros:
dependency: transitive
description: dart
source: sdk
version: "0.3.0"
analyzer:
dependency: transitive
description:
name: analyzer
sha256: "54ed16638d20ec7554a01887dca2e2a10aeddd134217bd1e695afae693a3d482"
url: "https://pub.dev"
source: hosted
version: "6.5.2"
animation_tools_dart:
dependency: transitive
description:
name: animation_tools_dart
sha256: b81591311683566ad020928015fb0c6e312ff780f712df8ff29c18f152519c8f
url: "https://pub.dev"
source: hosted
version: "0.0.4"
archive:
dependency: transitive
description:
name: archive
sha256: cb6a278ef2dbb298455e1a713bda08524a175630ec643a242c399c932a0a1f7d
url: "https://pub.dev"
source: hosted
version: "3.6.1"
args:
dependency: transitive
description:
name: args
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
async:
dependency: transitive
description:
name: async
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
cli_config:
dependency: transitive
description:
name: cli_config
sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec
url: "https://pub.dev"
source: hosted
version: "0.2.0"
cli_util:
dependency: transitive
description:
name: cli_util
sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19
url: "https://pub.dev"
source: hosted
version: "0.4.1"
collection:
dependency: transitive
description:
name: collection
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
url: "https://pub.dev"
source: hosted
version: "1.19.0"
convert:
dependency: transitive
description:
name: convert
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
url: "https://pub.dev"
source: hosted
version: "3.1.1"
coverage:
dependency: transitive
description:
name: coverage
sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
ffi:
dependency: "direct main"
description:
name: ffi
sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
ffigen:
dependency: "direct dev"
description:
name: ffigen
sha256: dead012f29db2be71ea152458f5eab600de98fbc244e01088ae6bf2616bceca7
url: "https://pub.dev"
source: hosted
version: "11.0.0"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
frontend_server_client:
dependency: transitive
description:
name: frontend_server_client
sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
url: "https://pub.dev"
source: hosted
version: "4.0.0"
glob:
dependency: transitive
description:
name: glob
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
url: "https://pub.dev"
source: hosted
version: "3.2.1"
http_parser:
dependency: transitive
description:
name: http_parser
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
url: "https://pub.dev"
source: hosted
version: "4.0.2"
io:
dependency: transitive
description:
name: io
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
js:
dependency: transitive
description:
name: js
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
url: "https://pub.dev"
source: hosted
version: "0.7.1"
lints:
dependency: "direct dev"
description:
name: lints
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "3.0.0"
logging:
dependency: transitive
description:
name: logging
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
macros:
dependency: transitive
description:
name: macros
sha256: "56dbee7418e9441a669ae47f72c0a31085a69eee5b42d2163509711a867e2b14"
url: "https://pub.dev"
source: hosted
version: "0.1.2-main.0"
matcher:
dependency: transitive
description:
name: matcher
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.16+1"
meta:
dependency: transitive
description:
name: meta
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.15.0"
mime:
dependency: transitive
description:
name: mime
sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2"
url: "https://pub.dev"
source: hosted
version: "1.0.5"
native_assets_cli:
dependency: transitive
description:
path: "pkgs/native_assets_cli"
ref: "99020084c4687be4c58c7115a167088c0441d1de"
resolved-ref: "99020084c4687be4c58c7115a167088c0441d1de"
url: "git@github.com:nmfisher/native.git"
source: git
version: "0.6.1-wip"
native_toolchain_c:
dependency: transitive
description:
path: "pkgs/native_toolchain_c"
ref: "99020084c4687be4c58c7115a167088c0441d1de"
resolved-ref: "99020084c4687be4c58c7115a167088c0441d1de"
url: "git@github.com:nmfisher/native.git"
source: git
version: "0.4.2"
node_preamble:
dependency: transitive
description:
name: node_preamble
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
url: "https://pub.dev"
source: hosted
version: "2.0.2"
package_config:
dependency: transitive
description:
name: package_config
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
path:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
pool:
dependency: transitive
description:
name: pool
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pub_semver:
dependency: transitive
description:
name: pub_semver
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
quiver:
dependency: transitive
description:
name: quiver
sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47
url: "https://pub.dev"
source: hosted
version: "3.2.1"
shelf:
dependency: transitive
description:
name: shelf
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
url: "https://pub.dev"
source: hosted
version: "1.4.1"
shelf_packages_handler:
dependency: transitive
description:
name: shelf_packages_handler
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
shelf_static:
dependency: transitive
description:
name: shelf_static
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
url: "https://pub.dev"
source: hosted
version: "1.1.2"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611"
url: "https://pub.dev"
source: hosted
version: "2.0.0"
source_map_stack_trace:
dependency: transitive
description:
name: source_map_stack_trace
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
source_maps:
dependency: transitive
description:
name: source_maps
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
url: "https://pub.dev"
source: hosted
version: "0.10.12"
source_span:
dependency: transitive
description:
name: source_span
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.2"
string_scanner:
dependency: transitive
description:
name: string_scanner
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.1"
test:
dependency: "direct dev"
description:
name: test
sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e"
url: "https://pub.dev"
source: hosted
version: "1.25.7"
test_api:
dependency: transitive
description:
name: test_api
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.7.2"
test_core:
dependency: transitive
description:
name: test_core
sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696"
url: "https://pub.dev"
source: hosted
version: "0.6.4"
thermion_dart:
dependency: "direct main"
description:
path: "../../../thermion_dart"
relative: true
source: path
version: "0.5.0"
tuple:
dependency: transitive
description:
name: tuple
sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151
url: "https://pub.dev"
source: hosted
version: "2.0.2"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
vector_math:
dependency: transitive
description:
name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
url: "https://pub.dev"
source: hosted
version: "14.2.4"
watcher:
dependency: transitive
description:
name: watcher
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
web:
dependency: transitive
description:
name: web
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
web_socket:
dependency: transitive
description:
name: web_socket
sha256: "24301d8c293ce6fe327ffe6f59d8fd8834735f0ec36e4fd383ec7ff8a64aa078"
url: "https://pub.dev"
source: hosted
version: "0.1.5"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
sha256: a2d56211ee4d35d9b344d9d4ce60f362e4f5d1aafb988302906bd732bc731276
url: "https://pub.dev"
source: hosted
version: "3.0.0"
webkit_inspection_protocol:
dependency: transitive
description:
name: webkit_inspection_protocol
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
url: "https://pub.dev"
source: hosted
version: "1.2.1"
yaml:
dependency: transitive
description:
name: yaml
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
yaml_edit:
dependency: transitive
description:
name: yaml_edit
sha256: e9c1a3543d2da0db3e90270dbb1e4eebc985ee5e3ffe468d83224472b2194a5f
url: "https://pub.dev"
source: hosted
version: "2.2.1"
sdks:
dart: ">=3.4.0 <4.0.0"

View File

@@ -0,0 +1,18 @@
name: example_cli
description: A sample command-line application.
version: 1.0.0
# repository: https://github.com/my_org/my_repo
environment:
sdk: ^3.3.0
# Add regular dependencies here.
dependencies:
thermion_dart:
path: ../../../thermion_dart
ffi:
dev_dependencies:
ffigen: ^11.0.0
lints: ^3.0.0
test: ^1.24.0

View File

@@ -0,0 +1,8 @@
import 'package:example_cli/example_cli.dart';
import 'package:test/test.dart';
void main() {
test('calculate', () {
expect(calculate(), 42);
});
}

3
examples/dart/cli_wasm/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/

View File

@@ -0,0 +1,3 @@
## 1.0.0
- Initial version.

View File

@@ -0,0 +1,2 @@
A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.

View File

@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.
include: package:lints/recommended.yaml
# Uncomment the following section to specify additional rules.
# linter:
# rules:
# - camel_case_types
# analyzer:
# exclude:
# - path/to/excluded/files/**
# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints
# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options

4
examples/dart/cli_wasm/bin/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
example_cli.mjs
example_cli.wasm
example_cli.unopt.wasm
node_modules/**/*

View File

@@ -0,0 +1,98 @@
MAIN
initializing
gto uberarchive ptr
create void ptr callback
resolve
try
done, returning
created
got promise [object Promise]
got fn ptr address 2720
Calling create_filament_viewer_ffi
Call complete
Created viewer, waiting for initialization
Creating WebGL context.
Created WebGL context 2.0
Made WebGL context current
FEngine (32 bits) created at 0x1937d0 (threading is disabled)
[stack-gl], [ANGLE], [OpenGL ES 3.0 (WebGL 1.0 stack-gl 8.0.2)], [OpenGL ES GLSL ES 1.00 (WebGL GLSL ES 1.0 stack-gl)]
Feature level: 1
Active workarounds:
Backend feature level: 1
FEngine feature level: 1
Set frame interval to 16.666666
Setting tone mapping to ACES
Bloom is disabled on WebGL builds as it causes instability with certain drivers. setBloom will be ignored
View created
Camera aperture 16.000000 shutter 0.008000 sensitivity 100.000000
Created ubershader provider.
Added imageEntity 6
Got void ptr callback
Set viewer to true
Created viewer 1652064
Initialied
Loading GLB from buffer of length 116948
Loaded glb
Entities : [10, 11, 12]
entityName : Cone
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
morph targets : [Key 1, Key 2, Key 3, Key 4, Key 5, Key 6, Key 7, Key 8]
entityName : Cube
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
morph targets : [Key 1, Key 2]
entityName : Cylinder
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
Getting morpht arget names
No insdtance
Using asset instance
morph targets : [Key 1, Key 2, Key 3, Key 4]

View File

@@ -0,0 +1,33 @@
import 'package:thermion_dart/thermion_dart/compatibility/compatibility.dart';
import 'package:thermion_dart/thermion_dart.dart';
import 'package:animation_tools_dart/animation_tools_dart.dart';
void main(List<String> args) async {
final resourceLoader = thermion_dart_web_get_resource_loader_wrapper();
var viewer = FilamentViewer(resourceLoader: resourceLoader.cast<Void>());
viewer.initialized.then((_) async {
var entity = await viewer.loadGlb(
"/Users/nickfisher/Documents/polyvox/apps/packages/thermion_flutter/thermion_flutter_federated/thermion_flutter/example/assets/shapes/shapes.glb");
var entities = await viewer.getChildEntities(entity, true);
for (final childEntity in entities) {
final childName = await viewer.getNameForEntity(childEntity);
var morphTargetNames =
await viewer.getMorphTargetNames(entity, childEntity!);
if (morphTargetNames.isNotEmpty) {
await viewer.setMorphTargetWeights(
childEntity, List<double>.filled(morphTargetNames.length, 1.0));
}
var animationData = MorphAnimationData(
List.generate(
10, (_) => List<double>.filled(morphTargetNames.length, 1.0)),
morphTargetNames);
await viewer.setMorphAnimationData(entity, animationData,
targetMeshNames: [childName!]);
}
});
while (true) {
await Future.delayed(Duration(seconds: 1));
}
}

View File

@@ -0,0 +1,123 @@
const fs = require('node:fs');
const thermion_dart = require("./thermion_dart.js")
const GLctx = require('gl')(100, 100, { preserveDrawingBuffer: true })
// queueMicrotask = (func) => {
// func();
// }
// read('thermion_dart.wasm', 'binary')
// const exports = {};
// const module = {};
const wasmBuffer = fs.readFileSync('thermion_dart.wasm');
var dartFilamentModulePromise = WebAssembly.compile(wasmBuffer);
let globalDf;
thermion_dart({
dartFilamentResolveCallback: (cb, data) => {
const fn = globalDf.wasmTable.get(cb);
if(data) {
fn(data);
} else {
fn();
}
},
ctx:GLctx}).then((df) => {
globalDf = df;
createVoidCallback = () => {
let res; //placeholder for resolver callback, outside of promise
const promise = new Promise((resolve, reject) => {
res = resolve;
});
try {
const callback = () => {
try {
res({});
} catch(err) {
console.log(err);
}
}
const fnPtr = df.addFunction(callback, 'v');
return [promise, fnPtr];
} catch(err) {
console.log(err);
return null;
}
}
createIntCallback = () => {
let res;
const promise = new Promise((resolve, reject) => {
res = resolve;
});
try {
const callback = (val) => {
try {
res(val);
} catch(err) {
console.log(err);
}
}
const fnPtr = df.addFunction(callback, 'vi');
return [promise, fnPtr];
} catch(err) {
console.log(err);
return null;
}
}
createVoidPointerCallback = () => {
console.log("create void ptr callback");
let res; //placeholder for resolver callback, outside of promise
const promise = new Promise((resolve, reject) => {
console.log("resolve");
res = resolve;
});
try {
console.log("try");
const callback = (voidPtr) => {
try {
res(voidPtr);
} catch(err) {
console.log(err);
}
}
const fnPtr = df.addFunction(callback, 'vi');
console.log("done, returning");
return [promise, fnPtr];
} catch(err) {
console.log(err);
return null;
}
}
createBoolCallback = () => {
let res; //placeholder for resolver callback, outside of promise
const promise = new Promise((resolve, reject) => {
res = resolve;
});
try {
const callback = (val) => {
try {
res(val);
} catch(err) {
console.log(err);
}
}
const fnPtr = df.addFunction(callback, 'vi');
return [promise, fnPtr];
} catch(err) {
console.log(err);
return null;
}
}
import('./example_cli.mjs').then((dart2wasm_runtime) => {
var dartModulePromise = WebAssembly.compile(fs.readFileSync('./example_cli.wasm'));
const imports = {"thermion_dart": df, "ctx": GLctx};
dart2wasm_runtime.instantiate(dartModulePromise, imports).then((moduleInstance) => {
dart2wasm_runtime.invoke(moduleInstance);
});
});
});
// // dartModulePromise.then((dartModule) => { console.log(dartModule.exports); dart2wasm_runtime.invoke(dartModule, imports);}); });

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,5 @@
{
"dependencies": {
"gl": "^8.0.2"
}
}

View File

@@ -0,0 +1 @@
../../../native/web/build/build/out/dart_filament.js

View File

@@ -0,0 +1 @@
../../../native/web/build/build/out/dart_filament.wasm

View File

@@ -0,0 +1 @@
../../../native/web/build/build/out/dart_filament.worker.js

View File

@@ -0,0 +1,18 @@
name: example_cli
description: A sample command-line application.
version: 1.0.0
# repository: https://github.com/my_org/my_repo
environment:
sdk: ^3.3.0
# Add regular dependencies here.
dependencies:
thermion_dart:
path: ../../
ffi:
dev_dependencies:
ffigen: ^11.0.0
lints: ^3.0.0
test: ^1.24.0

View File

@@ -0,0 +1,8 @@
import 'package:example_cli/example_cli.dart';
import 'package:test/test.dart';
void main() {
test('calculate', () {
expect(calculate(), 42);
});
}

3
examples/dart/web_wasm/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/

View File

@@ -0,0 +1,3 @@
## 1.0.0
- Initial version.

View File

@@ -0,0 +1,2 @@
A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.

View File

@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.
include: package:lints/recommended.yaml
# Uncomment the following section to specify additional rules.
# linter:
# rules:
# - camel_case_types
# analyzer:
# exclude:
# - path/to/excluded/files/**
# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints
# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options

View File

@@ -0,0 +1,16 @@
# Flight Helmet
## Screenshot
![screenshot](screenshot/screenshot.jpg)
## License Information
Donated by Microsoft for glTF testing
[![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/)
To the extent possible under law, Microsoft has waived all copyright and related or neighboring rights to this asset.
Draco compression was done via Cesium tools on 27-03-2020 as follows.
gltf-pipeline -i FlightHelmet.gltf -o FlightHelmet.gltf -d -s --keep-unused-elements

View File

@@ -0,0 +1 @@
../../../../flutter_filament_federated/flutter_filament/example/assets

View File

@@ -0,0 +1,57 @@
import 'dart:js_interop';
import 'dart:js_interop_unsafe';
import 'package:thermion_dart/thermion_dart/compatibility/compatibility.dart';
import 'package:thermion_dart/thermion_dart/filament_viewer_impl.dart';
import 'package:web/web.dart';
void main(List<String> arguments) async {
var fc = FooChar();
final canvas = document.getElementById("canvas") as HTMLCanvasElement;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
var resourceLoader = thermion_dart_web_get_resource_loader_wrapper();
var viewer = FilamentViewer(resourceLoader: resourceLoader);
var mousedown = (JSObject event) {
var x = event.getProperty("clientX".toJS) as JSNumber;
var y = event.getProperty("clientY".toJS) as JSNumber;
viewer.rotateStart(x.toDartDouble, y.toDartDouble);
};
canvas.addEventListener("mousedown", mousedown.toJS);
var mousemove = (JSObject event) {
var x = event.getProperty("clientX".toJS) as JSNumber;
var y = event.getProperty("clientY".toJS) as JSNumber;
viewer.rotateUpdate(x.toDartDouble, y.toDartDouble);
};
canvas.addEventListener("mousemove", mousemove.toJS);
var mouseup = (JSObject event) {
viewer.rotateEnd();
};
canvas.addEventListener("mouseup", mousedown.toJS);
await viewer.initialized;
var width = window.innerWidth;
var height = window.innerHeight;
await viewer.createSwapChain(width.toDouble(), height.toDouble());
await viewer.setBackgroundColor(0.0, 1.0, 1.0, 1.0);
await viewer.loadSkybox("assets/default_env_skybox.ktx");
await viewer.loadIbl("assets/default_env_ibl.ktx");
await viewer.loadGltf("assets/FlightHelmet.gltf", "assets");
await viewer.updateViewportAndCameraProjection(
width.toDouble(), height.toDouble());
await viewer.setPostProcessing(true);
await viewer.setRendering(true);
while (true) {
await Future.delayed(Duration(milliseconds: 16));
}
print("Finisehd!");
}

View File

@@ -0,0 +1,249 @@
let buildArgsList;
// `modulePromise` is a promise to the `WebAssembly.module` object to be
// instantiated.
// `importObjectPromise` is a promise to an object that contains any additional
// imports needed by the module that aren't provided by the standard runtime.
// The fields on this object will be merged into the importObject with which
// the module will be instantiated.
// This function returns a promise to the instantiated module.
export const instantiate = async (modulePromise, importObjectPromise) => {
let dartInstance;
function stringFromDartString(string) {
const totalLength = dartInstance.exports.$stringLength(string);
let result = '';
let index = 0;
while (index < totalLength) {
let chunkLength = Math.min(totalLength - index, 0xFFFF);
const array = new Array(chunkLength);
for (let i = 0; i < chunkLength; i++) {
array[i] = dartInstance.exports.$stringRead(string, index++);
}
result += String.fromCharCode(...array);
}
return result;
}
function stringToDartString(string) {
const length = string.length;
let range = 0;
for (let i = 0; i < length; i++) {
range |= string.codePointAt(i);
}
if (range < 256) {
const dartString = dartInstance.exports.$stringAllocate1(length);
for (let i = 0; i < length; i++) {
dartInstance.exports.$stringWrite1(dartString, i, string.codePointAt(i));
}
return dartString;
} else {
const dartString = dartInstance.exports.$stringAllocate2(length);
for (let i = 0; i < length; i++) {
dartInstance.exports.$stringWrite2(dartString, i, string.charCodeAt(i));
}
return dartString;
}
}
// Prints to the console
function printToConsole(value) {
if (typeof dartPrint == "function") {
dartPrint(value);
return;
}
if (typeof console == "object" && typeof console.log != "undefined") {
console.log(value);
return;
}
if (typeof print == "function") {
print(value);
return;
}
throw "Unable to print message: " + js;
}
// Converts a Dart List to a JS array. Any Dart objects will be converted, but
// this will be cheap for JSValues.
function arrayFromDartList(constructor, list) {
const length = dartInstance.exports.$listLength(list);
const array = new constructor(length);
for (let i = 0; i < length; i++) {
array[i] = dartInstance.exports.$listRead(list, i);
}
return array;
}
buildArgsList = function(list) {
const dartList = dartInstance.exports.$makeStringList();
for (let i = 0; i < list.length; i++) {
dartInstance.exports.$listAdd(dartList, stringToDartString(list[i]));
}
return dartList;
}
// A special symbol attached to functions that wrap Dart functions.
const jsWrappedDartFunctionSymbol = Symbol("JSWrappedDartFunction");
function finalizeWrapper(dartFunction, wrapped) {
wrapped.dartFunction = dartFunction;
wrapped[jsWrappedDartFunctionSymbol] = true;
return wrapped;
}
// Imports
const dart2wasm = {
_18: f => finalizeWrapper(f,x0 => dartInstance.exports._18(f,x0)),
_19: f => finalizeWrapper(f,x0 => dartInstance.exports._19(f,x0)),
_75: (x0,x1) => x0.getElementById(x1),
_76: f => finalizeWrapper(f,x0 => dartInstance.exports._76(f,x0)),
_77: (x0,x1,x2) => x0.addEventListener(x1,x2),
_78: f => finalizeWrapper(f,x0 => dartInstance.exports._78(f,x0)),
_79: f => finalizeWrapper(f,x0 => dartInstance.exports._79(f,x0)),
_1499: (x0,x1) => x0.width = x1,
_1501: (x0,x1) => x0.height = x1,
_1878: () => globalThis.window,
_1920: x0 => x0.innerWidth,
_1921: x0 => x0.innerHeight,
_6854: () => globalThis.document,
_12721: () => globalThis.createBoolCallback(),
_12722: () => globalThis.createVoidPointerCallback(),
_12723: () => globalThis.createVoidCallback(),
_12727: v => stringToDartString(v.toString()),
_12743: () => {
let stackString = new Error().stack.toString();
let frames = stackString.split('\n');
let drop = 2;
if (frames[0] === 'Error') {
drop += 1;
}
return frames.slice(drop).join('\n');
},
_12762: s => stringToDartString(JSON.stringify(stringFromDartString(s))),
_12763: s => printToConsole(stringFromDartString(s)),
_12777: (ms, c) =>
setTimeout(() => dartInstance.exports.$invokeCallback(c),ms),
_12781: (c) =>
queueMicrotask(() => dartInstance.exports.$invokeCallback(c)),
_12783: (a, i) => a.push(i),
_12794: a => a.length,
_12796: (a, i) => a[i],
_12797: (a, i, v) => a[i] = v,
_12799: a => a.join(''),
_12809: (s, p, i) => s.indexOf(p, i),
_12812: (o, start, length) => new Uint8Array(o.buffer, o.byteOffset + start, length),
_12813: (o, start, length) => new Int8Array(o.buffer, o.byteOffset + start, length),
_12814: (o, start, length) => new Uint8ClampedArray(o.buffer, o.byteOffset + start, length),
_12815: (o, start, length) => new Uint16Array(o.buffer, o.byteOffset + start, length),
_12816: (o, start, length) => new Int16Array(o.buffer, o.byteOffset + start, length),
_12817: (o, start, length) => new Uint32Array(o.buffer, o.byteOffset + start, length),
_12818: (o, start, length) => new Int32Array(o.buffer, o.byteOffset + start, length),
_12821: (o, start, length) => new Float32Array(o.buffer, o.byteOffset + start, length),
_12822: (o, start, length) => new Float64Array(o.buffer, o.byteOffset + start, length),
_12827: (o) => new DataView(o.buffer, o.byteOffset, o.byteLength),
_12831: Function.prototype.call.bind(Object.getOwnPropertyDescriptor(DataView.prototype, 'byteLength').get),
_12832: (b, o) => new DataView(b, o),
_12834: Function.prototype.call.bind(DataView.prototype.getUint8),
_12836: Function.prototype.call.bind(DataView.prototype.getInt8),
_12838: Function.prototype.call.bind(DataView.prototype.getUint16),
_12840: Function.prototype.call.bind(DataView.prototype.getInt16),
_12842: Function.prototype.call.bind(DataView.prototype.getUint32),
_12844: Function.prototype.call.bind(DataView.prototype.getInt32),
_12850: Function.prototype.call.bind(DataView.prototype.getFloat32),
_12852: Function.prototype.call.bind(DataView.prototype.getFloat64),
_12873: o => o === undefined,
_12874: o => typeof o === 'boolean',
_12875: o => typeof o === 'number',
_12877: o => typeof o === 'string',
_12880: o => o instanceof Int8Array,
_12881: o => o instanceof Uint8Array,
_12882: o => o instanceof Uint8ClampedArray,
_12883: o => o instanceof Int16Array,
_12884: o => o instanceof Uint16Array,
_12885: o => o instanceof Int32Array,
_12886: o => o instanceof Uint32Array,
_12887: o => o instanceof Float32Array,
_12888: o => o instanceof Float64Array,
_12889: o => o instanceof ArrayBuffer,
_12890: o => o instanceof DataView,
_12891: o => o instanceof Array,
_12892: o => typeof o === 'function' && o[jsWrappedDartFunctionSymbol] === true,
_12896: (l, r) => l === r,
_12897: o => o,
_12898: o => o,
_12899: o => o,
_12900: b => !!b,
_12901: o => o.length,
_12904: (o, i) => o[i],
_12905: f => f.dartFunction,
_12906: l => arrayFromDartList(Int8Array, l),
_12907: l => arrayFromDartList(Uint8Array, l),
_12908: l => arrayFromDartList(Uint8ClampedArray, l),
_12909: l => arrayFromDartList(Int16Array, l),
_12910: l => arrayFromDartList(Uint16Array, l),
_12911: l => arrayFromDartList(Int32Array, l),
_12912: l => arrayFromDartList(Uint32Array, l),
_12913: l => arrayFromDartList(Float32Array, l),
_12914: l => arrayFromDartList(Float64Array, l),
_12915: (data, length) => {
const view = new DataView(new ArrayBuffer(length));
for (let i = 0; i < length; i++) {
view.setUint8(i, dartInstance.exports.$byteDataGetUint8(data, i));
}
return view;
},
_12916: l => arrayFromDartList(Array, l),
_12917: stringFromDartString,
_12918: stringToDartString,
_12921: l => new Array(l),
_12925: (o, p) => o[p],
_12929: o => String(o),
_12930: (p, s, f) => p.then(s, f),
_12949: (o, p) => o[p]
};
const baseImports = {
dart2wasm: dart2wasm,
Math: Math,
Date: Date,
Object: Object,
Array: Array,
Reflect: Reflect,
};
const jsStringPolyfill = {
"charCodeAt": (s, i) => s.charCodeAt(i),
"compare": (s1, s2) => {
if (s1 < s2) return -1;
if (s1 > s2) return 1;
return 0;
},
"concat": (s1, s2) => s1 + s2,
"equals": (s1, s2) => s1 === s2,
"fromCharCode": (i) => String.fromCharCode(i),
"length": (s) => s.length,
"substring": (s, a, b) => s.substring(a, b),
};
dartInstance = await WebAssembly.instantiate(await modulePromise, {
...baseImports,
...(await importObjectPromise),
"wasm:js-string": jsStringPolyfill,
});
return dartInstance;
}
// Call the main function for the instantiated module
// `moduleInstance` is the instantiated dart2wasm module
// `args` are any arguments that should be passed into the main function.
export const invoke = (moduleInstance, ...args) => {
const dartMain = moduleInstance.exports.$getMain();
const dartArgs = buildArgsList(args);
moduleInstance.exports.$invokeMain(dartMain, dartArgs);
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,127 @@
<html>
<head>
<script src="thermion_dart.js"></script>
<style>
html, body {
margin:0;
padding:0;
}
canvas {
position:absolute;
left:0;
right:0;
top:0;
bottom:0;
width:100%;
height:100%;
}
</style>
</head>
<script type="module">
window.resolveCallback = (cb, data) => {
const fn = window.df.wasmTable.get(cb);
if(data) {
fn(data);
} else {
fn();
}
}
window.createVoidCallback = () => {
let res; //placeholder for resolver callback, outside of promise
const promise = new Promise((resolve, reject) => {
res = resolve;
});
try {
const callback = () => {
try {
res({});
} catch(err) {
console.log(err);
}
}
const fnPtr = window.df.addFunction(callback, 'v');
return [promise, fnPtr];
} catch(err) {
console.log(err);
return null;
}
}
window.createIntCallback = () => {
let res;
const promise = new Promise((resolve, reject) => {
res = resolve;
});
try {
const callback = (val) => {
try {
res(val);
} catch(err) {
console.log(err);
}
}
const fnPtr = window.df.addFunction(callback, 'vi');
return [promise, fnPtr];
} catch(err) {
console.log(err);
return null;
}
}
window.createVoidPointerCallback = () => {
let res; //placeholder for resolver callback, outside of promise
const promise = new Promise((resolve, reject) => {
res = resolve;
});
try {
const callback = (voidPtr) => {
try {
res(voidPtr);
} catch(err) {
console.log(err);
}
}
const fnPtr = window.df.addFunction(callback, 'vi');
return [promise, fnPtr];
} catch(err) {
console.log(err);
return null;
}
}
window.createBoolCallback = () => {
let res; //placeholder for resolver callback, outside of promise
const promise = new Promise((resolve, reject) => {
res = resolve;
});
try {
const callback = (val) => {
try {
res(val);
} catch(err) {
console.log(err);
}
}
const fnPtr = window.df.addFunction(callback, 'vi');
return [promise, fnPtr];
} catch(err) {
console.log(err);
return null;
}
}
const df = await thermion_dart();
window.df = df;
const dartModulePromise = WebAssembly.compileStreaming(fetch('example_web.wasm'));
const imports = {"thermion_dart":df};
const dart2wasm_runtime = await import('./example_web.mjs');
const moduleInstance = await dart2wasm_runtime.instantiate(dartModulePromise, imports);
window.example = moduleInstance;
await dart2wasm_runtime.invoke(moduleInstance);
</script>
<body>
<canvas id="canvas"></canvas>
</body>
</html>

View File

@@ -0,0 +1 @@
../../../native/web/build/build/out/dart_filament.js

View File

@@ -0,0 +1 @@
../../../native/web/build/build/out/dart_filament.wasm

View File

@@ -0,0 +1 @@
../../../native/web/build/build/out/dart_filament.worker.js

View File

@@ -0,0 +1,17 @@
name: example_web
description: A sample command-line application.
version: 1.0.0
# repository: https://github.com/my_org/my_repo
environment:
sdk: ^3.3.0
# Add regular dependencies here.
dependencies:
thermion_dart:
path: ../../
ffi:
dev_dependencies:
lints: ^3.0.0
test: ^1.24.0

View File

@@ -0,0 +1,8 @@
import 'package:example_web/example_web.dart';
import 'package:test/test.dart';
void main() {
test('calculate', () {
expect(calculate(), 42);
});
}

View File

@@ -0,0 +1,4 @@
{
"flutterSdkVersion": "3.16.0-0.2.pre",
"flavors": {}
}

30
examples/flutter/example/.gitattributes vendored Normal file
View File

@@ -0,0 +1,30 @@
assets/lit_opaque_43.uberz filter=lfs diff=lfs merge=lfs -text
assets/BusterDrone filter=lfs diff=lfs merge=lfs -text
assets/FlightHelmet filter=lfs diff=lfs merge=lfs -text
assets/lit_opaque_32.uberz filter=lfs diff=lfs merge=lfs -text
windows/lib/**/*.* filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/12_Settonemappingtolinear.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/3_loadIBL.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/6_zoomin.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/13_Movecameratoasset.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/14_movecamerato.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/7_rotate.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/9_transformtounitcube.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/0_fresh.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/10_setshapespositionto.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/2_loadskybox.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/4_Renderingfalse.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/8_pan.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/11_Disablefrustumculling.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/15_setcameratofirstcamerainshapesGLB.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/1_createviewerdefaultubershader.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/5_loadshapesGLB.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/16_resize.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/3_loadskybox.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/4_loadIBL.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/19_resize.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/17_resize.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/2_Renderingfalse.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/18_resize.png filter=lfs diff=lfs merge=lfs -text
integration_test/goldens/ios/diffs filter=lfs diff=lfs merge=lfs -text

50
examples/flutter/example/.gitignore vendored Normal file
View File

@@ -0,0 +1,50 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Web related
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
/android/.cxx/**/*
# fvm
.fvm/flutter_sdk

View File

@@ -0,0 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: "12d54de962782853206992fedce29723fcb4a95b"
channel: "master"
project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 12d54de962782853206992fedce29723fcb4a95b
base_revision: 12d54de962782853206992fedce29723fcb4a95b
- platform: macos
create_revision: 12d54de962782853206992fedce29723fcb4a95b
base_revision: 12d54de962782853206992fedce29723fcb4a95b
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'

View File

@@ -0,0 +1,21 @@
# thermion_flutter_example
Demonstrates how to use the thermion_flutter plugin.
## Linux
export PKG_CONFIG_PATH=/usr/lib/pkgconfig/:/usr/lib64/pkgconfig/
export CPLUS_INCLUDE_PATH=/usr/include/gtk-3.0/:/usr/include/pango-1.0/:/usr/include/harfbuzz:/usr/include/cairo/:/usr/include/gdk-pixbuf-2.0/:/usr/include/atk-1.0/
## Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

View File

@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options

View File

@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks

View File

@@ -0,0 +1,51 @@
plugins {
id "com.android.application"
id "kotlin-android"
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id "dev.flutter.flutter-gradle-plugin"
}
android {
namespace = "app.polyvox.example"
compileSdkVersion 34
ndkVersion "25.2.9519653"
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "app.polyvox.example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdk = 30
targetSdk = 31
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
release {
signingConfig = signingConfigs.debug
shrinkResources false
minifyEnabled false
}
debug {
}
}
}
dependencies {
implementation 'net.java.dev.jna:jna:5.10.0@aar'
}
flutter {
source = "../.."
}

View File

@@ -0,0 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>

View File

@@ -0,0 +1,45 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:taskAffinity=""
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
<!-- Required to query activities that can process text, see:
https://developer.android.com/training/package-visibility and
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
<queries>
<intent>
<action android:name="android.intent.action.PROCESS_TEXT"/>
<data android:mimeType="text/plain"/>
</intent>
</queries>
</manifest>

View File

@@ -0,0 +1,5 @@
package app.polyvox.example
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity()

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>

Some files were not shown because too many files have changed in this diff Show More