Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(examples): the model-import sample plays what it imported

esengine8190e2cd0dc4
diff --git a/examples/model-import/assets/models/robot.esprefab b/examples/model-import/assets/models/robot.esprefab
index 501f9f300..596fce487 100644
--- a/examples/model-import/assets/models/robot.esprefab
+++ b/examples/model-import/assets/models/robot.esprefab
@@ -22,6 +22,13 @@
"z": 0
}
}
+ },
+ {
+ "type": "TimelinePlayer",
+ "data": {
+ "timeline": "assets/models/robot_Raise.estimeline",
+ "playing": false
+ }
}
]
},
diff --git a/examples/model-import/assets/models/robot.gltf b/examples/model-import/assets/models/robot.gltf
index a39441cfd..87eaea3ce 100644
--- a/examples/model-import/assets/models/robot.gltf
+++ b/examples/model-import/assets/models/robot.gltf
@@ -5,8 +5,8 @@
},
"buffers": [
{
- "byteLength": 280,
- "uri": "data:application/octet-stream;base64,AADwwgAAcEIAAAAAAADwQgAAcEIAAAAAAADwwgAAcMIAAAAAAADwQgAAcMIAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAPwAAgD8AAAIAAQABAAIAAwAAAHDCAACgQQAAAAAAAHBCAACgQQAAAAAAAHDCAACgwQAAAAAAAHBCAACgwQAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAIA/AACAPwAAAgABAAEAAgADAA=="
+ "byteLength": 312,
+ "uri": "data:application/octet-stream;base64,AADwwgAAcEIAAAAAAADwQgAAcEIAAAAAAADwwgAAcMIAAAAAAADwQgAAcMIAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AACAPwAAgD8AAAIAAQABAAIAAwAAAHDCAACgQQAAAAAAAHBCAACgQQAAAAAAAHDCAACgwQAAAAAAAHBCAACgwQAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAIA/AACAPwAAAgABAAEAAgADAAAAAAAAAIA+AAAAAAAA3EIAAAAAAAAAAAAAIEMAAAAA"
}
],
"bufferViews": [
@@ -49,6 +49,16 @@
"buffer": 0,
"byteOffset": 268,
"byteLength": 12
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 280,
+ "byteLength": 8
+ },
+ {
+ "buffer": 0,
+ "byteOffset": 288,
+ "byteLength": 24
}
],
"accessors": [
@@ -119,6 +129,24 @@
"componentType": 5123,
"count": 6,
"type": "SCALAR"
+ },
+ {
+ "bufferView": 8,
+ "componentType": 5126,
+ "count": 2,
+ "type": "SCALAR",
+ "min": [
+ 0
+ ],
+ "max": [
+ 0.25
+ ]
+ },
+ {
+ "bufferView": 9,
+ "componentType": 5126,
+ "count": 2,
+ "type": "VEC3"
}
],
"images": [
@@ -247,5 +275,26 @@
]
}
],
- "scene": 0
+ "scene": 0,
+ "animations": [
+ {
+ "name": "Raise",
+ "channels": [
+ {
+ "sampler": 0,
+ "target": {
+ "node": 2,
+ "path": "translation"
+ }
+ }
+ ],
+ "samplers": [
+ {
+ "input": 8,
+ "output": 9,
+ "interpolation": "LINEAR"
+ }
+ ]
+ }
+ ]
}
diff --git a/examples/model-import/assets/models/robot_Raise.estimeline b/examples/model-import/assets/models/robot_Raise.estimeline
new file mode 100644
index 000000000..7bde2913a
--- /dev/null
+++ b/examples/model-import/assets/models/robot_Raise.estimeline
@@ -0,0 +1,73 @@
+{
+ "version": "1.2",
+ "type": "timeline",
+ "duration": 0.25,
+ "wrapMode": "once",
+ "tracks": [
+ {
+ "type": "property",
+ "name": "Banner",
+ "childPath": "Banner",
+ "component": "Transform",
+ "channels": [
+ {
+ "property": "position.x",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 0.25,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ },
+ {
+ "property": "position.y",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 110,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 0.25,
+ "value": 160,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ },
+ {
+ "property": "position.z",
+ "keyframes": [
+ {
+ "time": 0,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ },
+ {
+ "time": 0.25,
+ "value": 0,
+ "inTangent": 0,
+ "outTangent": 0,
+ "interpolation": "linear"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/examples/model-import/assets/models/robot_Raise.estimeline.meta b/examples/model-import/assets/models/robot_Raise.estimeline.meta
new file mode 100644
index 000000000..f55542a33
--- /dev/null
+++ b/examples/model-import/assets/models/robot_Raise.estimeline.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "2f6a1078-0308-4b15-8a1f-0158721d9b63",
+ "version": "2.0",
+ "type": "animation",
+ "importer": {}
+}
diff --git a/examples/model-import/assets/scenes/main.esscene b/examples/model-import/assets/scenes/main.esscene
index 69eba2493..1cc1a6413 100644
--- a/examples/model-import/assets/scenes/main.esscene
+++ b/examples/model-import/assets/scenes/main.esscene
@@ -9,8 +9,25 @@
"children": [],
"visible": true,
"components": [
- { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 10 } } },
- { "type": "Camera", "data": { "projectionType": 1, "orthoSize": 110, "isActive": true, "priority": 0 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 110,
+ "isActive": true,
+ "priority": 0
+ }
+ }
]
},
{
@@ -20,15 +37,49 @@
"children": [],
"visible": true,
"components": [
- { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 0 } } },
- { "type": "Light2D", "data": { "type": 1, "color": { "r": 1, "g": 1, "b": 1, "a": 1 }, "intensity": 1, "direction": { "x": 0, "y": 0 }, "enabled": true } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Light2D",
+ "data": {
+ "type": 1,
+ "color": {
+ "r": 1,
+ "g": 1,
+ "b": 1,
+ "a": 1
+ },
+ "intensity": 1,
+ "direction": {
+ "x": 0,
+ "y": 0
+ },
+ "enabled": true
+ }
+ }
]
},
{
"id": 2,
"parent": null,
"prefab": "assets/models/robot.esprefab",
- "overrides": [],
+ "overrides": [
+ {
+ "prefabEntityId": "n0",
+ "type": "property",
+ "componentType": "TimelinePlayer",
+ "propertyName": "playing",
+ "value": true
+ }
+ ],
"added": [],
"removed": []
}
diff --git a/tools/goldenProjects.mjs b/tools/goldenProjects.mjs
index c80402d59..2129c38f7 100644
--- a/tools/goldenProjects.mjs
+++ b/tools/goldenProjects.mjs
@@ -52,7 +52,7 @@ export const CAPABILITIES = [
'ecs', 'particles', 'audio',
'ui-layout', 'text', 'localization',
'spine', 'material', 'asset-lifecycle',
- 'model-import',
+ 'model-import', 'model-animation',
'tilemap', 'tile-collision',
'touch', 'safe-area', 'pause-resume',
'texture-atlas',
@@ -90,6 +90,8 @@ export const EVIDENCE = {
// The products, not the source: a .gltf in the project proves an import ran,
// and a scene referencing an .esmesh proves the products are what it draws.
'model-import': /\.esmesh\b/,
+ // The clip the import wrote, referenced by the prefab the scene places.
+ 'model-animation': /\.estimeline\b/,
'asset-lifecycle': /\b(Assets|loadGroup|releaseGroup|preload)\b/,
tilemap: /\bTilemap(Layer)?\b/,
'tile-collision': /\b(collision|Collider|tileCollision)\b/,
@@ -176,7 +178,7 @@ export const GOLDEN = [
},
{
id: 'model-import',
- certifies: ['model-import'],
+ certifies: ['model-import', 'model-animation'],
targets: ['web'],
tier: 'pr',
// Nothing in it responds to input: the scene is a placed model, and the