@zephyr3d/scene 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/animation/spring/spring_particle.js +4 -4
  2. package/dist/animation/spring/spring_particle.js.map +1 -1
  3. package/dist/app/engine.js +119 -71
  4. package/dist/app/engine.js.map +1 -1
  5. package/dist/asset/assetmanager.js +296 -244
  6. package/dist/asset/assetmanager.js.map +1 -1
  7. package/dist/asset/loaders/gltf/gltf_loader.js +1 -0
  8. package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
  9. package/dist/asset/model.js +57 -57
  10. package/dist/asset/model.js.map +1 -1
  11. package/dist/index.d.ts +684 -33
  12. package/dist/index.js +10 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/material/material.js +1 -1
  15. package/dist/material/material.js.map +1 -1
  16. package/dist/material/msdf_text.js +180 -0
  17. package/dist/material/msdf_text.js.map +1 -0
  18. package/dist/material/msdf_text_sprite.js +64 -0
  19. package/dist/material/msdf_text_sprite.js.map +1 -0
  20. package/dist/material/pbrblueprint.js +123 -108
  21. package/dist/material/pbrblueprint.js.map +1 -1
  22. package/dist/material/shader/helper.js +277 -277
  23. package/dist/material/shader/helper.js.map +1 -1
  24. package/dist/material/sprite_sdf.js +106 -0
  25. package/dist/material/sprite_sdf.js.map +1 -0
  26. package/dist/posteffect/ssr.js +1 -0
  27. package/dist/posteffect/ssr.js.map +1 -1
  28. package/dist/render/abuffer_oit.js +1 -0
  29. package/dist/render/abuffer_oit.js.map +1 -1
  30. package/dist/render/cluster_light.js.map +1 -1
  31. package/dist/render/cull_visitor.js +28 -0
  32. package/dist/render/cull_visitor.js.map +1 -1
  33. package/dist/render/drawable.js.map +1 -1
  34. package/dist/render/drawable_mixin.js +1 -0
  35. package/dist/render/drawable_mixin.js.map +1 -1
  36. package/dist/render/fbm_wavegenerator.js +1 -0
  37. package/dist/render/fbm_wavegenerator.js.map +1 -1
  38. package/dist/render/gerstner_wavegenerator.js +1 -0
  39. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  40. package/dist/render/globalbindgroup_allocator.js +1 -0
  41. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  42. package/dist/render/render_queue.js +1 -0
  43. package/dist/render/render_queue.js.map +1 -1
  44. package/dist/scene/basesprite.js +1 -5
  45. package/dist/scene/basesprite.js.map +1 -1
  46. package/dist/scene/batchgroup.js +29 -17
  47. package/dist/scene/batchgroup.js.map +1 -1
  48. package/dist/scene/environment.js +1 -0
  49. package/dist/scene/environment.js.map +1 -1
  50. package/dist/scene/mesh.js +86 -87
  51. package/dist/scene/mesh.js.map +1 -1
  52. package/dist/scene/meshdrawable.js +96 -0
  53. package/dist/scene/meshdrawable.js.map +1 -0
  54. package/dist/scene/msdftext.js +341 -0
  55. package/dist/scene/msdftext.js.map +1 -0
  56. package/dist/scene/msdftextsprite.js +349 -0
  57. package/dist/scene/msdftextsprite.js.map +1 -0
  58. package/dist/scene/particlesys.js +1 -0
  59. package/dist/scene/particlesys.js.map +1 -1
  60. package/dist/scene/scene.js +1 -0
  61. package/dist/scene/scene.js.map +1 -1
  62. package/dist/scene/scene_node.js +234 -228
  63. package/dist/scene/scene_node.js.map +1 -1
  64. package/dist/scene/sdftextsprite.js +322 -0
  65. package/dist/scene/sdftextsprite.js.map +1 -0
  66. package/dist/scene/terrain-cm/grass.js +1 -0
  67. package/dist/scene/terrain-cm/grass.js.map +1 -1
  68. package/dist/scene/terrain-cm/grassmaterial.js +1 -0
  69. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  70. package/dist/scene/terrain-cm/terrain-cm.js +1 -0
  71. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  72. package/dist/scene/textsprite.js +120 -0
  73. package/dist/scene/textsprite.js.map +1 -0
  74. package/dist/scene/water.js +1 -0
  75. package/dist/scene/water.js.map +1 -1
  76. package/dist/shadow/shader.js +1 -0
  77. package/dist/shadow/shader.js.map +1 -1
  78. package/dist/text/font/font_asset.js +884 -0
  79. package/dist/text/font/font_asset.js.map +1 -0
  80. package/dist/text/font/sfnt_reader.js +43 -0
  81. package/dist/text/font/sfnt_reader.js.map +1 -0
  82. package/dist/text/msdf/generator.js +417 -0
  83. package/dist/text/msdf/generator.js.map +1 -0
  84. package/dist/text/msdf/shape.js +143 -0
  85. package/dist/text/msdf/shape.js.map +1 -0
  86. package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
  87. package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
  88. package/dist/text/runtime/msdf_text_atlas_manager.js +47 -0
  89. package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
  90. package/dist/text/runtime/text_layout.js +96 -0
  91. package/dist/text/runtime/text_layout.js.map +1 -0
  92. package/dist/utility/blueprint/material/inputs.js +1275 -1091
  93. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  94. package/dist/utility/blueprint/material/ir.js +16 -1
  95. package/dist/utility/blueprint/material/ir.js.map +1 -1
  96. package/dist/utility/blueprint/material/pbr.js +32 -0
  97. package/dist/utility/blueprint/material/pbr.js.map +1 -1
  98. package/dist/utility/serialization/manager.js +321 -277
  99. package/dist/utility/serialization/manager.js.map +1 -1
  100. package/dist/utility/serialization/scene/animation.js +2 -0
  101. package/dist/utility/serialization/scene/animation.js.map +1 -1
  102. package/dist/utility/serialization/scene/batch.js +2 -0
  103. package/dist/utility/serialization/scene/batch.js.map +1 -1
  104. package/dist/utility/serialization/scene/camera.js +2 -0
  105. package/dist/utility/serialization/scene/camera.js.map +1 -1
  106. package/dist/utility/serialization/scene/light.js +2 -0
  107. package/dist/utility/serialization/scene/light.js.map +1 -1
  108. package/dist/utility/serialization/scene/material.js +1 -0
  109. package/dist/utility/serialization/scene/material.js.map +1 -1
  110. package/dist/utility/serialization/scene/mesh.js +2 -0
  111. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  112. package/dist/utility/serialization/scene/node.js +2 -0
  113. package/dist/utility/serialization/scene/node.js.map +1 -1
  114. package/dist/utility/serialization/scene/particle.js +2 -0
  115. package/dist/utility/serialization/scene/particle.js.map +1 -1
  116. package/dist/utility/serialization/scene/primitive.js +1 -0
  117. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  118. package/dist/utility/serialization/scene/sprite.js +2 -0
  119. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  120. package/dist/utility/serialization/scene/terrain.js +2 -0
  121. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  122. package/dist/utility/serialization/scene/text.js +516 -0
  123. package/dist/utility/serialization/scene/text.js.map +1 -0
  124. package/dist/utility/serialization/scene/water.js +2 -0
  125. package/dist/utility/serialization/scene/water.js.map +1 -1
  126. package/dist/utility/serialization/types.js.map +1 -1
  127. package/dist/values.js +48 -48
  128. package/dist/values.js.map +1 -1
  129. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { applyMixins, DRef } from '@zephyr3d/base';
1
+ import { castObservable, applyMixins, DRef } from '@zephyr3d/base';
2
2
  import { GraphNode } from './graph_node.js';
3
3
  import { ShaderHelper } from '../material/shader/helper.js';
4
4
  import { LambertMaterial } from '../material/lambert.js';
@@ -17,13 +17,15 @@ import '../material/pbrsg.js';
17
17
  import '../material/pbrblueprint.js';
18
18
  import '../material/sprite.js';
19
19
  import '../material/sprite_std.js';
20
+ import '../material/msdf_text.js';
20
21
  import '../utility/blueprint/material/texture.js';
21
22
  import { mixinDrawable } from '../render/drawable_mixin.js';
22
23
 
23
- /**
24
- * Mesh node
25
- * @public
26
- */ class Mesh extends applyMixins(GraphNode, mixinDrawable) {
24
+ const MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))();
25
+ /**
26
+ * Mesh node
27
+ * @public
28
+ */ class Mesh extends MeshBase {
27
29
  /** @internal */ _primitive;
28
30
  /** @internal */ _material;
29
31
  /** @internal */ _castShadow;
@@ -43,9 +45,9 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
43
45
  /** @internal */ _materialChangeTag;
44
46
  /** @internal */ _primitiveChangeTag;
45
47
  /** @internal */ _postUpdateCallbacks;
46
- /**
47
- * Creates an instance of mesh node
48
- * @param scene - The scene to which the mesh node belongs
48
+ /**
49
+ * Creates an instance of mesh node
50
+ * @param scene - The scene to which the mesh node belongs
49
51
  */ constructor(scene, primitive, material){
50
52
  super(scene);
51
53
  this._primitive = new DRef();
@@ -72,23 +74,18 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
72
74
  this._primitiveChangeTag = null;
73
75
  this._postUpdateCallbacks = new Set();
74
76
  }
75
- /**
76
- * {@inheritDoc Drawable.getName}
77
- */ getName() {
78
- return this._name;
79
- }
80
- /**
81
- * Returns the batch instance ID for the current render pass.
77
+ /**
78
+ * Returns the batch instance ID for the current render pass.
82
79
  */ getInstanceId(_renderPass) {
83
80
  return `${this._instanceHash}:${this.worldMatrixDet >= 0}`;
84
81
  }
85
- /**
86
- * Returns the packed instance-uniform buffer used for batching.
82
+ /**
83
+ * Returns the packed instance-uniform buffer used for batching.
87
84
  */ getInstanceUniforms() {
88
85
  return this._material.get().$instanceUniforms;
89
86
  }
90
- /**
91
- * {@inheritDoc Drawable.getPickTarget }
87
+ /**
88
+ * {@inheritDoc Drawable.getPickTarget }
92
89
  */ getPickTarget() {
93
90
  return this._pickTarget;
94
91
  }
@@ -123,7 +120,7 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
123
120
  this._castShadow = b;
124
121
  }
125
122
  /** Primitive of the mesh */ get primitive() {
126
- return this._primitive.get();
123
+ return this._primitive?.get() ?? null;
127
124
  }
128
125
  set primitive(prim) {
129
126
  const currentPrimitive = this._primitive.get();
@@ -139,10 +136,11 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
139
136
  this.invalidateBoundingVolume();
140
137
  RenderBundleWrapper.drawableChanged(this);
141
138
  this._primitiveChangeTag = null;
139
+ this.dispatchEvent('primitive_changed', prim);
142
140
  }
143
141
  }
144
142
  /** Material of the mesh */ get material() {
145
- return this._material.get();
143
+ return this._material?.get() ?? null;
146
144
  }
147
145
  set material(m) {
148
146
  if (this._material.get() !== m) {
@@ -153,28 +151,29 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
153
151
  this._instanceHash = this._primitive.get() && m ? `${this.constructor.name}:${this._scene?.id ?? 0}:${this._primitive.get().id}:${m.instanceId}` : null;
154
152
  RenderBundleWrapper.drawableChanged(this);
155
153
  this._materialChangeTag = null;
154
+ this.dispatchEvent('material_changed', m);
156
155
  }
157
156
  }
158
- /**
159
- * {@inheritDoc SceneNode.isMesh}
157
+ /**
158
+ * {@inheritDoc SceneNode.isMesh}
160
159
  */ isMesh() {
161
160
  return true;
162
161
  }
163
- /**
164
- * Sets the bounding box for animation
165
- * @param bbox - The bounding box for animation
162
+ /**
163
+ * Sets the bounding box for animation
164
+ * @param bbox - The bounding box for animation
166
165
  */ setAnimatedBoundingBox(bbox) {
167
166
  this._animatedBoundingBox = bbox;
168
167
  this.invalidateBoundingVolume();
169
168
  }
170
- /**
171
- * Gets the bounding box for animation
169
+ /**
170
+ * Gets the bounding box for animation
172
171
  */ getAnimatedBoundingBox() {
173
172
  return this._animatedBoundingBox ?? null;
174
173
  }
175
- /**
176
- * Sets the texture that contains the bone matrices for skeletal animation
177
- * @param matrices - The texture that contains the bone matrices
174
+ /**
175
+ * Sets the texture that contains the bone matrices for skeletal animation
176
+ * @param matrices - The texture that contains the bone matrices
178
177
  */ setBoneMatrices(matrices) {
179
178
  if (this._boneMatrices.get() !== matrices) {
180
179
  this._boneMatrices.set(matrices);
@@ -182,9 +181,9 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
182
181
  RenderBundleWrapper.drawableChanged(this);
183
182
  }
184
183
  }
185
- /**
186
- * Sets the texture that contains the morph target data
187
- * @param data - The texture that contains the morph target data
184
+ /**
185
+ * Sets the texture that contains the morph target data
186
+ * @param data - The texture that contains the morph target data
188
187
  */ setMorphData(data) {
189
188
  if (!data) {
190
189
  if (this._morphData) {
@@ -220,20 +219,20 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
220
219
  RenderBundleWrapper.drawableChanged(this);
221
220
  }
222
221
  }
223
- /**
224
- * Sets the skinned bounding info
225
- * @param info - The skinned bounding info
222
+ /**
223
+ * Sets the skinned bounding info
224
+ * @param info - The skinned bounding info
226
225
  */ setSkinnedBoundingInfo(info) {
227
226
  this._skinnedBoundingInfo = info;
228
227
  }
229
- /**
230
- * {@inheritDoc Drawable.getMorphData}
228
+ /**
229
+ * {@inheritDoc Drawable.getMorphData}
231
230
  */ getMorphData() {
232
231
  return this._morphData;
233
232
  }
234
- /**
235
- * Sets the buffer that contains the morph target information
236
- * @param info - The buffer that contains the morph target information
233
+ /**
234
+ * Sets the buffer that contains the morph target information
235
+ * @param info - The buffer that contains the morph target information
237
236
  */ setMorphInfo(info) {
238
237
  if (!info) {
239
238
  if (this._morphInfo) {
@@ -271,23 +270,23 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
271
270
  RenderBundleWrapper.drawableChanged(this);
272
271
  }
273
272
  }
274
- /**
275
- * {@inheritDoc Drawable.getMorphInfo}
273
+ /**
274
+ * {@inheritDoc Drawable.getMorphInfo}
276
275
  */ getMorphInfo() {
277
276
  return this._morphInfo;
278
277
  }
279
- /**
280
- * Get the number of morph targets
281
- *
282
- * @returns The number of morph targets
278
+ /**
279
+ * Get the number of morph targets
280
+ *
281
+ * @returns The number of morph targets
283
282
  */ getNumMorphTargets() {
284
283
  return this._morphInfo?.data[3] ?? 0;
285
284
  }
286
- /**
287
- * Get the name of the morph target by index
288
- *
289
- * @param index - The index of the morph target
290
- * @returns The name of the morph target, or null if not found
285
+ /**
286
+ * Get the name of the morph target by index
287
+ *
288
+ * @param index - The index of the morph target
289
+ * @returns The name of the morph target, or null if not found
291
290
  */ getMorphTargetName(index) {
292
291
  if (this._morphInfo && index >= 0 && index < this._morphInfo.data[3]) {
293
292
  const name = Object.keys(this._morphInfo.names).find((key)=>this._morphInfo.names[key] === index);
@@ -295,11 +294,11 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
295
294
  }
296
295
  return null;
297
296
  }
298
- /**
299
- * Update morph target weight
300
- *
301
- * @param name - The name of the morph target
302
- * @param weight - The weight of the morph target
297
+ /**
298
+ * Update morph target weight
299
+ *
300
+ * @param name - The name of the morph target
301
+ * @param weight - The weight of the morph target
303
302
  */ setMorphWeight(name, weight) {
304
303
  const index = this._morphInfo?.names?.[name];
305
304
  if (index !== undefined && index >= 0 && index < this._morphInfo.data[3]) {
@@ -312,11 +311,11 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
312
311
  console.warn(`Morph target ${name} not found`);
313
312
  }
314
313
  }
315
- /**
316
- * Get morph target weight
317
- *
318
- * @param name - The name of the morph target
319
- * @returns The weight of the morph target, or 0 if not found
314
+ /**
315
+ * Get morph target weight
316
+ *
317
+ * @param name - The name of the morph target
318
+ * @returns The weight of the morph target, or 0 if not found
320
319
  */ getMorphWeight(name) {
321
320
  const index = this._morphInfo?.names?.[name];
322
321
  if (index !== undefined && index >= 0 && index < this._morphInfo.data[3]) {
@@ -324,10 +323,10 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
324
323
  }
325
324
  return 0;
326
325
  }
327
- /**
328
- * Update morph target weight
329
- *
330
- * @param weight - The morph target weights. The length must not exceed the mesh's morph target count.
326
+ /**
327
+ * Update morph target weight
328
+ *
329
+ * @param weight - The morph target weights. The length must not exceed the mesh's morph target count.
331
330
  */ updateMorphWeights(weight) {
332
331
  if (this._morphInfo && weight && weight.length <= this._morphInfo.data[3]) {
333
332
  this._morphInfo.data.set(weight, 4);
@@ -355,28 +354,28 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
355
354
  this._postUpdateCallbacks.delete(callback);
356
355
  }
357
356
  }
358
- /**
359
- * {@inheritDoc Drawable.isBatchable}
357
+ /**
358
+ * {@inheritDoc Drawable.isBatchable}
360
359
  */ isBatchable() {
361
360
  return this._batchable && !this._boneMatrices.get() && !this._morphData && (this._material.get()?.isBatchable() ?? false);
362
361
  }
363
- /**
364
- * {@inheritDoc Drawable.getQueueType}
362
+ /**
363
+ * {@inheritDoc Drawable.getQueueType}
365
364
  */ getQueueType() {
366
365
  return this.material?.getQueueType() ?? QUEUE_OPAQUE;
367
366
  }
368
- /**
369
- * {@inheritDoc Drawable.isUnlit}
367
+ /**
368
+ * {@inheritDoc Drawable.isUnlit}
370
369
  */ isUnlit() {
371
370
  return !this.material?.supportLighting();
372
371
  }
373
- /**
374
- * {@inheritDoc Drawable.needSceneColor}
372
+ /**
373
+ * {@inheritDoc Drawable.needSceneColor}
375
374
  */ needSceneColor() {
376
375
  return this.material?.needSceneColor() ?? false;
377
376
  }
378
- /**
379
- * {@inheritDoc Drawable.needSceneDepth}
377
+ /**
378
+ * {@inheritDoc Drawable.needSceneDepth}
380
379
  */ needSceneDepth() {
381
380
  return this.material?.needSceneDepth() ?? false;
382
381
  }
@@ -406,8 +405,8 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
406
405
  this.scene.queueUpdateNode(this);
407
406
  }
408
407
  }
409
- /**
410
- * {@inheritDoc Drawable.draw}
408
+ /**
409
+ * {@inheritDoc Drawable.draw}
411
410
  */ draw(ctx, renderQueue, hash) {
412
411
  const material = this.material;
413
412
  const primitive = this.primitive;
@@ -433,23 +432,23 @@ import { mixinDrawable } from '../render/drawable_mixin.js';
433
432
  }
434
433
  }
435
434
  }
436
- /**
437
- * {@inheritDoc Drawable.getMaterial}
435
+ /**
436
+ * {@inheritDoc Drawable.getMaterial}
438
437
  */ getMaterial() {
439
438
  return this.material;
440
439
  }
441
- /**
442
- * {@inheritDoc Drawable.getPrimitive}
440
+ /**
441
+ * {@inheritDoc Drawable.getPrimitive}
443
442
  */ getPrimitive() {
444
443
  return this.primitive;
445
444
  }
446
- /**
447
- * {@inheritDoc Drawable.getBoneMatrices}
445
+ /**
446
+ * {@inheritDoc Drawable.getBoneMatrices}
448
447
  */ getBoneMatrices() {
449
448
  return this._boneMatrices.get();
450
449
  }
451
- /**
452
- * {@inheritDoc Drawable.getNode}
450
+ /**
451
+ * {@inheritDoc Drawable.getNode}
453
452
  */ getNode() {
454
453
  // mesh transform should be ignored when skinned
455
454
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"mesh.js","sources":["../../src/scene/mesh.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\nimport { applyMixins, DRef } from '@zephyr3d/base';\nimport { GraphNode } from './graph_node';\nimport type { MeshMaterial } from '../material';\nimport { LambertMaterial, ShaderHelper } from '../material';\nimport type {\n RenderPass,\n Primitive,\n BatchDrawable,\n DrawContext,\n PickTarget,\n MorphData,\n MorphInfo,\n RenderQueue\n} from '../render';\nimport {\n PBArrayTypeInfo,\n PBPrimitiveType,\n PBPrimitiveTypeInfo,\n PBStructTypeInfo,\n type RenderBundle,\n type Texture2D\n} from '@zephyr3d/device';\nimport type { Scene } from './scene';\nimport type { BoundingVolume } from '../utility/bounding_volume';\nimport type { BoundingBox } from '../utility/bounding_volume';\nimport { MORPH_ATTRIBUTE_VECTOR_COUNT, MORPH_WEIGHTS_VECTOR_COUNT, QUEUE_OPAQUE } from '../values';\nimport { mixinDrawable } from '../render/drawable_mixin';\nimport { RenderBundleWrapper } from '../render/renderbundle_wrapper';\nimport type { SceneNode } from './scene_node';\nimport { getDevice } from '../app/api';\nimport type { SkinnedBoundingBox } from '../animation';\n\n/**\n * Callback invoked after a mesh finishes its per-frame update.\n *\n * @public\n */\nexport type MeshUpdateCallback = (frameId: number, elapsedInSeconds: number, deltaInSeconds: number) => void;\n/**\n * Mesh node\n * @public\n */\nexport class Mesh extends applyMixins(GraphNode, mixinDrawable) implements BatchDrawable {\n /** @internal */\n private readonly _primitive: DRef<Primitive>;\n /** @internal */\n private readonly _material: DRef<MeshMaterial>;\n /** @internal */\n protected _castShadow: boolean;\n /** @internal */\n protected _skinnedBoundingInfo: Nullable<SkinnedBoundingBox>;\n /** @internal */\n protected _animatedBoundingBox: Nullable<BoundingBox>;\n /** @internal */\n protected _skeletonName: string;\n /** @internal */\n protected _boneMatrices: DRef<Texture2D>;\n /** @internal */\n protected _morphData: Nullable<MorphData>;\n /** @internal */\n protected _morphInfo: Nullable<MorphInfo>;\n /** @internal */\n protected _morphDirty: boolean;\n /** @internal */\n protected _instanceHash: Nullable<string>;\n /** @internal */\n protected _batchable: boolean;\n /** @internal */\n protected _pickTarget: PickTarget;\n /** @internal */\n protected _suspendSkinning: boolean;\n /** @internal */\n protected _renderBundle: Nullable<Record<string, RenderBundle>>;\n /** @internal */\n protected _useRenderBundle: boolean;\n /** @internal */\n protected _materialChangeTag: Nullable<number>;\n /** @internal */\n protected _primitiveChangeTag: Nullable<number>;\n /** @internal */\n protected _postUpdateCallbacks: Set<MeshUpdateCallback>;\n /**\n * Creates an instance of mesh node\n * @param scene - The scene to which the mesh node belongs\n */\n constructor(scene: Scene, primitive?: Primitive, material?: MeshMaterial) {\n super(scene);\n this._primitive = new DRef();\n this._material = new DRef();\n this._castShadow = true;\n this._skinnedBoundingInfo = null;\n this._animatedBoundingBox = null;\n this._boneMatrices = new DRef();\n this._morphData = null;\n this._morphInfo = null;\n this._morphDirty = false;\n this._instanceHash = null;\n this._pickTarget = { node: this };\n this._batchable = getDevice().type !== 'webgl';\n this.primitive = primitive ?? null;\n this.material = material ?? Mesh._getDefaultMaterial();\n this._suspendSkinning = false;\n this._skeletonName = '';\n this._renderBundle = {};\n this._useRenderBundle = true;\n this._materialChangeTag = null;\n this._primitiveChangeTag = null;\n this._postUpdateCallbacks = new Set();\n }\n /**\n * {@inheritDoc Drawable.getName}\n */\n getName() {\n return this._name;\n }\n /**\n * Returns the batch instance ID for the current render pass.\n */\n getInstanceId(_renderPass: RenderPass) {\n return `${this._instanceHash}:${this.worldMatrixDet >= 0}`;\n }\n /**\n * Returns the packed instance-uniform buffer used for batching.\n */\n getInstanceUniforms() {\n return this._material.get()!.$instanceUniforms;\n }\n /**\n * {@inheritDoc Drawable.getPickTarget }\n */\n getPickTarget() {\n return this._pickTarget;\n }\n setPickTarget(node: SceneNode, label?: string) {\n this._pickTarget = { node, label };\n }\n get skeletonName() {\n return this._skeletonName;\n }\n set skeletonName(name) {\n if (name !== this._skeletonName) {\n this._skeletonName = name;\n this.updateSkeletonState();\n }\n }\n /** @internal */\n get skinnedBoundingInfo() {\n return this._skinnedBoundingInfo;\n }\n /** @internal */\n get suspendSkinning() {\n return this._suspendSkinning;\n }\n /** @internal */\n set suspendSkinning(val) {\n this._suspendSkinning = !!val;\n }\n /** Wether the mesh node casts shadows */\n get castShadow() {\n return this._castShadow;\n }\n set castShadow(b) {\n this._castShadow = b;\n }\n /** Primitive of the mesh */\n get primitive() {\n return this._primitive.get();\n }\n set primitive(prim) {\n const currentPrimitive = this._primitive.get();\n if (prim !== currentPrimitive) {\n if (currentPrimitive) {\n currentPrimitive.off('bv_changed', this._onBoundingboxChange, this);\n }\n this._primitive.set(prim);\n if (prim) {\n prim.on('bv_changed', this._onBoundingboxChange, this);\n }\n this._instanceHash =\n prim && this._material.get()\n ? `${this.constructor.name}:${this._scene!.id}:${prim.id}:${this._material.get()!.instanceId}`\n : null;\n this.invalidateBoundingVolume();\n RenderBundleWrapper.drawableChanged(this);\n this._primitiveChangeTag = null;\n }\n }\n /** Material of the mesh */\n get material() {\n return this._material.get();\n }\n set material(m) {\n if (this._material.get() !== m) {\n this._material.set(m);\n if (m) {\n RenderBundleWrapper.materialAttached(m.coreMaterial, this);\n }\n this._instanceHash =\n this._primitive.get() && m\n ? `${this.constructor.name}:${this._scene?.id ?? 0}:${this._primitive.get()!.id}:${m.instanceId}`\n : null;\n RenderBundleWrapper.drawableChanged(this);\n this._materialChangeTag = null;\n }\n }\n /**\n * {@inheritDoc SceneNode.isMesh}\n */\n isMesh(): this is Mesh {\n return true;\n }\n /**\n * Sets the bounding box for animation\n * @param bbox - The bounding box for animation\n */\n setAnimatedBoundingBox(bbox: Nullable<BoundingBox>) {\n this._animatedBoundingBox = bbox;\n this.invalidateBoundingVolume();\n }\n /**\n * Gets the bounding box for animation\n */\n getAnimatedBoundingBox() {\n return this._animatedBoundingBox ?? null;\n }\n /**\n * Sets the texture that contains the bone matrices for skeletal animation\n * @param matrices - The texture that contains the bone matrices\n */\n setBoneMatrices(matrices: Nullable<Texture2D>) {\n if (this._boneMatrices.get() !== matrices) {\n this._boneMatrices.set(matrices);\n this._renderBundle = {};\n RenderBundleWrapper.drawableChanged(this);\n }\n }\n /**\n * Sets the texture that contains the morph target data\n * @param data - The texture that contains the morph target data\n */\n setMorphData(data: Nullable<MorphData>) {\n if (!data) {\n if (this._morphData) {\n this._morphData?.texture?.dispose();\n this._morphData = null;\n this._renderBundle = {};\n RenderBundleWrapper.drawableChanged(this);\n }\n } else {\n if (!this._morphData) {\n this._morphData = {\n texture: new DRef()\n } as MorphData;\n }\n this._morphData.width = data.width;\n this._morphData.height = data.height;\n this._morphData.data = data.data.slice();\n if (data.texture?.get()) {\n this._morphData.texture!.set(data.texture.get());\n } else {\n const tex = getDevice().createTexture2D('rgba32f', data.width, data.height, {\n mipmapping: false,\n samplerOptions: {\n minFilter: 'nearest',\n magFilter: 'nearest',\n mipFilter: 'none'\n }\n })!;\n tex.update(data.data, 0, 0, data.width, data.height);\n this._morphData.texture!.set(tex);\n }\n this._renderBundle = {};\n RenderBundleWrapper.drawableChanged(this);\n }\n }\n /**\n * Sets the skinned bounding info\n * @param info - The skinned bounding info\n */\n setSkinnedBoundingInfo(info: Nullable<SkinnedBoundingBox>) {\n this._skinnedBoundingInfo = info;\n }\n /**\n * {@inheritDoc Drawable.getMorphData}\n */\n getMorphData() {\n return this._morphData;\n }\n /**\n * Sets the buffer that contains the morph target information\n * @param info - The buffer that contains the morph target information\n */\n setMorphInfo(info: Nullable<MorphInfo>) {\n if (!info) {\n if (this._morphInfo) {\n this._morphInfo.buffer?.dispose();\n this._morphInfo = null;\n this._renderBundle = {};\n RenderBundleWrapper.drawableChanged(this);\n }\n } else {\n if (!this._morphInfo) {\n this._morphInfo = {\n buffer: new DRef()\n } as MorphInfo;\n }\n this._morphInfo.data = info.data.slice();\n this._morphInfo.names = { ...info.names };\n if (info.buffer?.get()) {\n this._morphInfo.buffer!.set(info.buffer.get());\n } else {\n const bufferType = new PBStructTypeInfo('dummy', 'std140', [\n {\n name: ShaderHelper.getMorphInfoUniformName(),\n type: new PBArrayTypeInfo(\n new PBPrimitiveTypeInfo(PBPrimitiveType.F32VEC4),\n 1 + MORPH_WEIGHTS_VECTOR_COUNT + MORPH_ATTRIBUTE_VECTOR_COUNT\n )\n }\n ]);\n const morphUniformBuffer = getDevice().createStructuredBuffer(\n bufferType,\n {\n usage: 'uniform'\n },\n info.data\n );\n this._morphInfo.buffer!.set(morphUniformBuffer);\n }\n this._morphDirty = false;\n this._renderBundle = {};\n RenderBundleWrapper.drawableChanged(this);\n }\n }\n /**\n * {@inheritDoc Drawable.getMorphInfo}\n */\n getMorphInfo() {\n return this._morphInfo;\n }\n /**\n * Get the number of morph targets\n *\n * @returns The number of morph targets\n */\n getNumMorphTargets(): number {\n return this._morphInfo?.data[3] ?? 0;\n }\n /**\n * Get the name of the morph target by index\n *\n * @param index - The index of the morph target\n * @returns The name of the morph target, or null if not found\n */\n getMorphTargetName(index: number): Nullable<string> {\n if (this._morphInfo && index >= 0 && index < this._morphInfo.data[3]) {\n const name = Object.keys(this._morphInfo.names).find((key) => this._morphInfo!.names![key] === index);\n return name ?? null;\n }\n return null;\n }\n /**\n * Update morph target weight\n *\n * @param name - The name of the morph target\n * @param weight - The weight of the morph target\n */\n setMorphWeight(name: string, weight: number) {\n const index = this._morphInfo?.names?.[name];\n if (index !== undefined && index >= 0 && index < this._morphInfo!.data[3]) {\n if (this._morphInfo!.data[4 + index] !== weight) {\n this._morphInfo!.data[4 + index] = weight;\n this._morphDirty = true;\n this.scene!.queueUpdateNode(this);\n }\n } else {\n console.warn(`Morph target ${name} not found`);\n }\n }\n /**\n * Get morph target weight\n *\n * @param name - The name of the morph target\n * @returns The weight of the morph target, or 0 if not found\n */\n getMorphWeight(name: string): number {\n const index = this._morphInfo?.names?.[name];\n if (index !== undefined && index >= 0 && index < this._morphInfo!.data[3]) {\n return this._morphInfo!.data[4 + index];\n }\n return 0;\n }\n /**\n * Update morph target weight\n *\n * @param weight - The morph target weights. The length must not exceed the mesh's morph target count.\n */\n updateMorphWeights(weight: number[]) {\n if (this._morphInfo && weight && weight.length <= this._morphInfo.data[3]) {\n this._morphInfo.data.set(weight, 4);\n this._morphDirty = true;\n this.scene!.queueUpdateNode(this);\n }\n }\n /** {@inheritDoc SceneNode.update} */\n update(frameId: number, elapsedInSeconds: number, deltaInSeconds: number) {\n super.update(frameId, elapsedInSeconds, deltaInSeconds);\n this.updateSkeletonState();\n this.updateMorphState();\n if (this._postUpdateCallbacks.size > 0) {\n for (const callback of this._postUpdateCallbacks) {\n callback(frameId, elapsedInSeconds, deltaInSeconds);\n }\n }\n }\n /** @internal */\n addPostUpdateCallback(callback: MeshUpdateCallback) {\n if (callback) {\n this._postUpdateCallbacks.add(callback);\n }\n }\n /** @internal */\n removePostUpdateCallback(callback: MeshUpdateCallback) {\n if (callback) {\n this._postUpdateCallbacks.delete(callback);\n }\n }\n /**\n * {@inheritDoc Drawable.isBatchable}\n */\n isBatchable(): this is BatchDrawable {\n return (\n this._batchable &&\n !this._boneMatrices.get() &&\n !this._morphData &&\n (this._material.get()?.isBatchable() ?? false)\n );\n }\n /**\n * {@inheritDoc Drawable.getQueueType}\n */\n getQueueType() {\n return this.material?.getQueueType() ?? QUEUE_OPAQUE;\n }\n /**\n * {@inheritDoc Drawable.isUnlit}\n */\n isUnlit() {\n return !this.material?.supportLighting();\n }\n /**\n * {@inheritDoc Drawable.needSceneColor}\n */\n needSceneColor() {\n return this.material?.needSceneColor() ?? false;\n }\n /**\n * {@inheritDoc Drawable.needSceneDepth}\n */\n needSceneDepth() {\n return this.material?.needSceneDepth() ?? false;\n }\n /** @internal */\n private updateMorphState() {\n if (this._morphInfo && this._morphDirty) {\n console.log(`jawOpen: ${this._morphInfo.data[20]}`);\n this._morphInfo.buffer!.get()!.bufferSubData(4 * 4, this._morphInfo.data, 4, this._morphInfo.data[3]);\n this._morphDirty = false;\n }\n }\n /** @internal */\n private updateSkeletonState() {\n if (this._suspendSkinning) {\n this.setBoneMatrices(null);\n this.setAnimatedBoundingBox(null);\n return;\n }\n const skeleton = this._skeletonName && this.findSkeletonById(this._skeletonName);\n if (skeleton) {\n this.setBoneMatrices(skeleton.jointTexture);\n skeleton.computeBoundingBox(this._skinnedBoundingInfo!, this.invWorldMatrix);\n this.setAnimatedBoundingBox(this._skinnedBoundingInfo!.boundingBox);\n } else {\n this.setBoneMatrices(null);\n this.setAnimatedBoundingBox(null);\n }\n if (this._skeletonName) {\n this.scene!.queueUpdateNode(this);\n }\n }\n /**\n * {@inheritDoc Drawable.draw}\n */\n draw(ctx: DrawContext, renderQueue: Nullable<RenderQueue>, hash?: string) {\n const material = this.material;\n const primitive = this.primitive;\n if (material && primitive) {\n if (this._useRenderBundle && !ctx.instanceData && hash) {\n if (\n this._primitiveChangeTag !== primitive.changeTag ||\n this._materialChangeTag !== material.changeTag\n ) {\n this._renderBundle = {};\n this._primitiveChangeTag = primitive.changeTag;\n this._materialChangeTag = material.changeTag;\n }\n const renderBundle = this._renderBundle![hash];\n if (!renderBundle) {\n ctx.device.beginCapture();\n this.bind(ctx, renderQueue);\n material.draw(primitive, ctx);\n this._renderBundle![hash] = ctx.device.endCapture();\n } else {\n ctx.device.executeRenderBundle(renderBundle);\n }\n } else {\n this.bind(ctx, renderQueue);\n material.draw(primitive, ctx);\n }\n }\n }\n /**\n * {@inheritDoc Drawable.getMaterial}\n */\n getMaterial() {\n return this.material;\n }\n /**\n * {@inheritDoc Drawable.getPrimitive}\n */\n getPrimitive() {\n return this.primitive;\n }\n /**\n * {@inheritDoc Drawable.getBoneMatrices}\n */\n getBoneMatrices() {\n return this._boneMatrices.get();\n }\n /**\n * {@inheritDoc Drawable.getNode}\n */\n getNode() {\n // mesh transform should be ignored when skinned\n return this;\n }\n /** @internal */\n computeBoundingVolume() {\n let bbox: Nullable<BoundingVolume>;\n if (this._animatedBoundingBox) {\n bbox = this._animatedBoundingBox;\n } else {\n bbox = this._primitive.get()?.getBoundingVolume() ?? null;\n }\n return bbox;\n }\n /** Disposes the mesh node */\n protected onDispose() {\n super.onDispose();\n this._primitive.get()?.off('bv_changed', this._onBoundingboxChange, this);\n this._primitive.dispose();\n this._material.dispose();\n this._boneMatrices.dispose();\n this.setMorphData(null);\n this.setMorphInfo(null);\n this._renderBundle = null;\n RenderBundleWrapper.drawableChanged(this);\n }\n /** @internal */\n private _onBoundingboxChange() {\n this.invalidateBoundingVolume();\n }\n /** @internal */\n private static _defaultMaterial: Nullable<MeshMaterial> = null;\n /** @internal */\n private static _getDefaultMaterial() {\n if (!this._defaultMaterial) {\n this._defaultMaterial = new LambertMaterial();\n }\n return this._defaultMaterial;\n }\n}\n"],"names":["Mesh","applyMixins","GraphNode","mixinDrawable","scene","primitive","material","_primitive","DRef","_material","_castShadow","_skinnedBoundingInfo","_animatedBoundingBox","_boneMatrices","_morphData","_morphInfo","_morphDirty","_instanceHash","_pickTarget","node","_batchable","getDevice","type","_getDefaultMaterial","_suspendSkinning","_skeletonName","_renderBundle","_useRenderBundle","_materialChangeTag","_primitiveChangeTag","_postUpdateCallbacks","Set","getName","_name","getInstanceId","_renderPass","worldMatrixDet","getInstanceUniforms","get","$instanceUniforms","getPickTarget","setPickTarget","label","skeletonName","name","updateSkeletonState","skinnedBoundingInfo","suspendSkinning","val","castShadow","b","prim","currentPrimitive","off","_onBoundingboxChange","set","on","_scene","id","instanceId","invalidateBoundingVolume","RenderBundleWrapper","drawableChanged","m","materialAttached","coreMaterial","isMesh","setAnimatedBoundingBox","bbox","getAnimatedBoundingBox","setBoneMatrices","matrices","setMorphData","data","texture","dispose","width","height","slice","tex","createTexture2D","mipmapping","samplerOptions","minFilter","magFilter","mipFilter","update","setSkinnedBoundingInfo","info","getMorphData","setMorphInfo","buffer","names","bufferType","PBStructTypeInfo","ShaderHelper","getMorphInfoUniformName","PBArrayTypeInfo","PBPrimitiveTypeInfo","PBPrimitiveType","F32VEC4","MORPH_WEIGHTS_VECTOR_COUNT","MORPH_ATTRIBUTE_VECTOR_COUNT","morphUniformBuffer","createStructuredBuffer","usage","getMorphInfo","getNumMorphTargets","getMorphTargetName","index","Object","keys","find","key","setMorphWeight","weight","undefined","queueUpdateNode","console","warn","getMorphWeight","updateMorphWeights","length","frameId","elapsedInSeconds","deltaInSeconds","updateMorphState","size","callback","addPostUpdateCallback","add","removePostUpdateCallback","delete","isBatchable","getQueueType","QUEUE_OPAQUE","isUnlit","supportLighting","needSceneColor","needSceneDepth","log","bufferSubData","skeleton","findSkeletonById","jointTexture","computeBoundingBox","invWorldMatrix","boundingBox","draw","ctx","renderQueue","hash","instanceData","changeTag","renderBundle","device","beginCapture","bind","endCapture","executeRenderBundle","getMaterial","getPrimitive","getBoneMatrices","getNode","computeBoundingVolume","getBoundingVolume","onDispose","_defaultMaterial","LambertMaterial"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCA;;;AAGC,IACM,MAAMA,IAAaC,SAAAA,WAAAA,CAAYC,SAAWC,EAAAA,aAAAA,CAAAA,CAAAA;qBAE/C,UAA6C;qBAE7C,SAA+C;qBAE/C,WAA+B;qBAE/B,oBAA6D;qBAE7D,oBAAsD;qBAEtD,aAAgC;qBAEhC,aAAyC;qBAEzC,UAA0C;qBAE1C,UAA0C;qBAE1C,WAA+B;qBAE/B,aAA0C;qBAE1C,UAA8B;qBAE9B,WAAkC;qBAElC,gBAAoC;qBAEpC,aAAgE;qBAEhE,gBAAoC;qBAEpC,kBAA+C;qBAE/C,mBAAgD;qBAEhD,oBAAwD;AACxD;;;AAGC,MACD,YAAYC,KAAY,EAAEC,SAAqB,EAAEC,QAAuB,CAAE;AACxE,QAAA,KAAK,CAACF,KAAAA,CAAAA;QACN,IAAI,CAACG,UAAU,GAAG,IAAIC,IAAAA,EAAAA;QACtB,IAAI,CAACC,SAAS,GAAG,IAAID,IAAAA,EAAAA;QACrB,IAAI,C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A;AACnC,QAAA,IAAI,CAAC,IAAI,CAACgJ,gBAAgB,EAAE;YAC1B,IAAI,CAACA,gBAAgB,GAAG,IAAIC,eAAAA,EAAAA;AAC9B;QACA,OAAO,IAAI,CAACD,gBAAgB;AAC9B;AACF;;;;"}
1
+ {"version":3,"file":"mesh.js","sources":["../../src/scene/mesh.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { applyMixins, castObservable, DRef } from '@zephyr3d/base';\r\nimport { GraphNode } from './graph_node';\r\nimport type { MeshMaterial } from '../material';\r\nimport { LambertMaterial, ShaderHelper } from '../material';\r\nimport type {\r\n RenderPass,\r\n Primitive,\r\n BatchDrawable,\r\n DrawContext,\r\n PickTarget,\r\n MorphData,\r\n MorphInfo,\r\n RenderQueue\r\n} from '../render';\r\nimport {\r\n PBArrayTypeInfo,\r\n PBPrimitiveType,\r\n PBPrimitiveTypeInfo,\r\n PBStructTypeInfo,\r\n type RenderBundle,\r\n type Texture2D\r\n} from '@zephyr3d/device';\r\nimport type { Scene } from './scene';\r\nimport type { BoundingVolume } from '../utility/bounding_volume';\r\nimport type { BoundingBox } from '../utility/bounding_volume';\r\nimport { MORPH_ATTRIBUTE_VECTOR_COUNT, MORPH_WEIGHTS_VECTOR_COUNT, QUEUE_OPAQUE } from '../values';\r\nimport { mixinDrawable } from '../render/drawable_mixin';\r\nimport { RenderBundleWrapper } from '../render/renderbundle_wrapper';\r\nimport type { SceneNode } from './scene_node';\r\nimport { getDevice } from '../app/api';\r\nimport type { SkinnedBoundingBox } from '../animation';\r\n\r\n/**\r\n * Callback invoked after a mesh finishes its per-frame update.\r\n *\r\n * @public\r\n */\r\nexport type MeshUpdateCallback = (frameId: number, elapsedInSeconds: number, deltaInSeconds: number) => void;\r\n\r\nconst MeshBase = castObservable(applyMixins(GraphNode, mixinDrawable))<{\r\n primitive_changed: [primitive: Nullable<Primitive>];\r\n material_changed: [material: Nullable<MeshMaterial>];\r\n}>();\r\n\r\n/**\r\n * Mesh node\r\n * @public\r\n */\r\nexport class Mesh extends MeshBase implements BatchDrawable {\r\n /** @internal */\r\n private readonly _primitive: DRef<Primitive>;\r\n /** @internal */\r\n private readonly _material: DRef<MeshMaterial>;\r\n /** @internal */\r\n protected _castShadow: boolean;\r\n /** @internal */\r\n protected _skinnedBoundingInfo: Nullable<SkinnedBoundingBox>;\r\n /** @internal */\r\n protected _animatedBoundingBox: Nullable<BoundingBox>;\r\n /** @internal */\r\n protected _skeletonName: string;\r\n /** @internal */\r\n protected _boneMatrices: DRef<Texture2D>;\r\n /** @internal */\r\n protected _morphData: Nullable<MorphData>;\r\n /** @internal */\r\n protected _morphInfo: Nullable<MorphInfo>;\r\n /** @internal */\r\n protected _morphDirty: boolean;\r\n /** @internal */\r\n protected _instanceHash: Nullable<string>;\r\n /** @internal */\r\n protected _batchable: boolean;\r\n /** @internal */\r\n protected _pickTarget: PickTarget;\r\n /** @internal */\r\n protected _suspendSkinning: boolean;\r\n /** @internal */\r\n protected _renderBundle: Nullable<Record<string, RenderBundle>>;\r\n /** @internal */\r\n protected _useRenderBundle: boolean;\r\n /** @internal */\r\n protected _materialChangeTag: Nullable<number>;\r\n /** @internal */\r\n protected _primitiveChangeTag: Nullable<number>;\r\n /** @internal */\r\n protected _postUpdateCallbacks: Set<MeshUpdateCallback>;\r\n /**\r\n * Creates an instance of mesh node\r\n * @param scene - The scene to which the mesh node belongs\r\n */\r\n constructor(scene: Scene, primitive?: Primitive, material?: MeshMaterial) {\r\n super(scene);\r\n this._primitive = new DRef();\r\n this._material = new DRef();\r\n this._castShadow = true;\r\n this._skinnedBoundingInfo = null;\r\n this._animatedBoundingBox = null;\r\n this._boneMatrices = new DRef();\r\n this._morphData = null;\r\n this._morphInfo = null;\r\n this._morphDirty = false;\r\n this._instanceHash = null;\r\n this._pickTarget = { node: this };\r\n this._batchable = getDevice().type !== 'webgl';\r\n this.primitive = primitive ?? null;\r\n this.material = material ?? Mesh._getDefaultMaterial();\r\n this._suspendSkinning = false;\r\n this._skeletonName = '';\r\n this._renderBundle = {};\r\n this._useRenderBundle = true;\r\n this._materialChangeTag = null;\r\n this._primitiveChangeTag = null;\r\n this._postUpdateCallbacks = new Set();\r\n }\r\n /**\r\n * Returns the batch instance ID for the current render pass.\r\n */\r\n getInstanceId(_renderPass: RenderPass) {\r\n return `${this._instanceHash}:${this.worldMatrixDet >= 0}`;\r\n }\r\n /**\r\n * Returns the packed instance-uniform buffer used for batching.\r\n */\r\n getInstanceUniforms() {\r\n return this._material.get()!.$instanceUniforms;\r\n }\r\n /**\r\n * {@inheritDoc Drawable.getPickTarget }\r\n */\r\n getPickTarget() {\r\n return this._pickTarget;\r\n }\r\n setPickTarget(node: SceneNode, label?: string) {\r\n this._pickTarget = { node, label };\r\n }\r\n get skeletonName() {\r\n return this._skeletonName;\r\n }\r\n set skeletonName(name) {\r\n if (name !== this._skeletonName) {\r\n this._skeletonName = name;\r\n this.updateSkeletonState();\r\n }\r\n }\r\n /** @internal */\r\n get skinnedBoundingInfo() {\r\n return this._skinnedBoundingInfo;\r\n }\r\n /** @internal */\r\n get suspendSkinning() {\r\n return this._suspendSkinning;\r\n }\r\n /** @internal */\r\n set suspendSkinning(val) {\r\n this._suspendSkinning = !!val;\r\n }\r\n /** Wether the mesh node casts shadows */\r\n get castShadow() {\r\n return this._castShadow;\r\n }\r\n set castShadow(b) {\r\n this._castShadow = b;\r\n }\r\n /** Primitive of the mesh */\r\n get primitive() {\r\n return this._primitive?.get() ?? null;\r\n }\r\n set primitive(prim) {\r\n const currentPrimitive = this._primitive.get();\r\n if (prim !== currentPrimitive) {\r\n if (currentPrimitive) {\r\n currentPrimitive.off('bv_changed', this._onBoundingboxChange, this);\r\n }\r\n this._primitive.set(prim);\r\n if (prim) {\r\n prim.on('bv_changed', this._onBoundingboxChange, this);\r\n }\r\n this._instanceHash =\r\n prim && this._material.get()\r\n ? `${this.constructor.name}:${this._scene!.id}:${prim.id}:${this._material.get()!.instanceId}`\r\n : null;\r\n this.invalidateBoundingVolume();\r\n RenderBundleWrapper.drawableChanged(this);\r\n this._primitiveChangeTag = null;\r\n this.dispatchEvent('primitive_changed', prim);\r\n }\r\n }\r\n /** Material of the mesh */\r\n get material() {\r\n return this._material?.get() ?? null;\r\n }\r\n set material(m) {\r\n if (this._material.get() !== m) {\r\n this._material.set(m);\r\n if (m) {\r\n RenderBundleWrapper.materialAttached(m.coreMaterial, this);\r\n }\r\n this._instanceHash =\r\n this._primitive.get() && m\r\n ? `${this.constructor.name}:${this._scene?.id ?? 0}:${this._primitive.get()!.id}:${m.instanceId}`\r\n : null;\r\n RenderBundleWrapper.drawableChanged(this);\r\n this._materialChangeTag = null;\r\n this.dispatchEvent('material_changed', m);\r\n }\r\n }\r\n /**\r\n * {@inheritDoc SceneNode.isMesh}\r\n */\r\n isMesh(): this is Mesh {\r\n return true;\r\n }\r\n /**\r\n * Sets the bounding box for animation\r\n * @param bbox - The bounding box for animation\r\n */\r\n setAnimatedBoundingBox(bbox: Nullable<BoundingBox>) {\r\n this._animatedBoundingBox = bbox;\r\n this.invalidateBoundingVolume();\r\n }\r\n /**\r\n * Gets the bounding box for animation\r\n */\r\n getAnimatedBoundingBox() {\r\n return this._animatedBoundingBox ?? null;\r\n }\r\n /**\r\n * Sets the texture that contains the bone matrices for skeletal animation\r\n * @param matrices - The texture that contains the bone matrices\r\n */\r\n setBoneMatrices(matrices: Nullable<Texture2D>) {\r\n if (this._boneMatrices.get() !== matrices) {\r\n this._boneMatrices.set(matrices);\r\n this._renderBundle = {};\r\n RenderBundleWrapper.drawableChanged(this);\r\n }\r\n }\r\n /**\r\n * Sets the texture that contains the morph target data\r\n * @param data - The texture that contains the morph target data\r\n */\r\n setMorphData(data: Nullable<MorphData>) {\r\n if (!data) {\r\n if (this._morphData) {\r\n this._morphData?.texture?.dispose();\r\n this._morphData = null;\r\n this._renderBundle = {};\r\n RenderBundleWrapper.drawableChanged(this);\r\n }\r\n } else {\r\n if (!this._morphData) {\r\n this._morphData = {\r\n texture: new DRef()\r\n } as MorphData;\r\n }\r\n this._morphData.width = data.width;\r\n this._morphData.height = data.height;\r\n this._morphData.data = data.data.slice();\r\n if (data.texture?.get()) {\r\n this._morphData.texture!.set(data.texture.get());\r\n } else {\r\n const tex = getDevice().createTexture2D('rgba32f', data.width, data.height, {\r\n mipmapping: false,\r\n samplerOptions: {\r\n minFilter: 'nearest',\r\n magFilter: 'nearest',\r\n mipFilter: 'none'\r\n }\r\n })!;\r\n tex.update(data.data, 0, 0, data.width, data.height);\r\n this._morphData.texture!.set(tex);\r\n }\r\n this._renderBundle = {};\r\n RenderBundleWrapper.drawableChanged(this);\r\n }\r\n }\r\n /**\r\n * Sets the skinned bounding info\r\n * @param info - The skinned bounding info\r\n */\r\n setSkinnedBoundingInfo(info: Nullable<SkinnedBoundingBox>) {\r\n this._skinnedBoundingInfo = info;\r\n }\r\n /**\r\n * {@inheritDoc Drawable.getMorphData}\r\n */\r\n getMorphData() {\r\n return this._morphData;\r\n }\r\n /**\r\n * Sets the buffer that contains the morph target information\r\n * @param info - The buffer that contains the morph target information\r\n */\r\n setMorphInfo(info: Nullable<MorphInfo>) {\r\n if (!info) {\r\n if (this._morphInfo) {\r\n this._morphInfo.buffer?.dispose();\r\n this._morphInfo = null;\r\n this._renderBundle = {};\r\n RenderBundleWrapper.drawableChanged(this);\r\n }\r\n } else {\r\n if (!this._morphInfo) {\r\n this._morphInfo = {\r\n buffer: new DRef()\r\n } as MorphInfo;\r\n }\r\n this._morphInfo.data = info.data.slice();\r\n this._morphInfo.names = { ...info.names };\r\n if (info.buffer?.get()) {\r\n this._morphInfo.buffer!.set(info.buffer.get());\r\n } else {\r\n const bufferType = new PBStructTypeInfo('dummy', 'std140', [\r\n {\r\n name: ShaderHelper.getMorphInfoUniformName(),\r\n type: new PBArrayTypeInfo(\r\n new PBPrimitiveTypeInfo(PBPrimitiveType.F32VEC4),\r\n 1 + MORPH_WEIGHTS_VECTOR_COUNT + MORPH_ATTRIBUTE_VECTOR_COUNT\r\n )\r\n }\r\n ]);\r\n const morphUniformBuffer = getDevice().createStructuredBuffer(\r\n bufferType,\r\n {\r\n usage: 'uniform'\r\n },\r\n info.data\r\n );\r\n this._morphInfo.buffer!.set(morphUniformBuffer);\r\n }\r\n this._morphDirty = false;\r\n this._renderBundle = {};\r\n RenderBundleWrapper.drawableChanged(this);\r\n }\r\n }\r\n /**\r\n * {@inheritDoc Drawable.getMorphInfo}\r\n */\r\n getMorphInfo() {\r\n return this._morphInfo;\r\n }\r\n /**\r\n * Get the number of morph targets\r\n *\r\n * @returns The number of morph targets\r\n */\r\n getNumMorphTargets(): number {\r\n return this._morphInfo?.data[3] ?? 0;\r\n }\r\n /**\r\n * Get the name of the morph target by index\r\n *\r\n * @param index - The index of the morph target\r\n * @returns The name of the morph target, or null if not found\r\n */\r\n getMorphTargetName(index: number): Nullable<string> {\r\n if (this._morphInfo && index >= 0 && index < this._morphInfo.data[3]) {\r\n const name = Object.keys(this._morphInfo.names).find((key) => this._morphInfo!.names![key] === index);\r\n return name ?? null;\r\n }\r\n return null;\r\n }\r\n /**\r\n * Update morph target weight\r\n *\r\n * @param name - The name of the morph target\r\n * @param weight - The weight of the morph target\r\n */\r\n setMorphWeight(name: string, weight: number) {\r\n const index = this._morphInfo?.names?.[name];\r\n if (index !== undefined && index >= 0 && index < this._morphInfo!.data[3]) {\r\n if (this._morphInfo!.data[4 + index] !== weight) {\r\n this._morphInfo!.data[4 + index] = weight;\r\n this._morphDirty = true;\r\n this.scene!.queueUpdateNode(this);\r\n }\r\n } else {\r\n console.warn(`Morph target ${name} not found`);\r\n }\r\n }\r\n /**\r\n * Get morph target weight\r\n *\r\n * @param name - The name of the morph target\r\n * @returns The weight of the morph target, or 0 if not found\r\n */\r\n getMorphWeight(name: string): number {\r\n const index = this._morphInfo?.names?.[name];\r\n if (index !== undefined && index >= 0 && index < this._morphInfo!.data[3]) {\r\n return this._morphInfo!.data[4 + index];\r\n }\r\n return 0;\r\n }\r\n /**\r\n * Update morph target weight\r\n *\r\n * @param weight - The morph target weights. The length must not exceed the mesh's morph target count.\r\n */\r\n updateMorphWeights(weight: number[]) {\r\n if (this._morphInfo && weight && weight.length <= this._morphInfo.data[3]) {\r\n this._morphInfo.data.set(weight, 4);\r\n this._morphDirty = true;\r\n this.scene!.queueUpdateNode(this);\r\n }\r\n }\r\n /** {@inheritDoc SceneNode.update} */\r\n update(frameId: number, elapsedInSeconds: number, deltaInSeconds: number) {\r\n super.update(frameId, elapsedInSeconds, deltaInSeconds);\r\n this.updateSkeletonState();\r\n this.updateMorphState();\r\n if (this._postUpdateCallbacks.size > 0) {\r\n for (const callback of this._postUpdateCallbacks) {\r\n callback(frameId, elapsedInSeconds, deltaInSeconds);\r\n }\r\n }\r\n }\r\n /** @internal */\r\n addPostUpdateCallback(callback: MeshUpdateCallback) {\r\n if (callback) {\r\n this._postUpdateCallbacks.add(callback);\r\n }\r\n }\r\n /** @internal */\r\n removePostUpdateCallback(callback: MeshUpdateCallback) {\r\n if (callback) {\r\n this._postUpdateCallbacks.delete(callback);\r\n }\r\n }\r\n /**\r\n * {@inheritDoc Drawable.isBatchable}\r\n */\r\n isBatchable(): this is BatchDrawable {\r\n return (\r\n this._batchable &&\r\n !this._boneMatrices.get() &&\r\n !this._morphData &&\r\n (this._material.get()?.isBatchable() ?? false)\r\n );\r\n }\r\n /**\r\n * {@inheritDoc Drawable.getQueueType}\r\n */\r\n getQueueType() {\r\n return this.material?.getQueueType() ?? QUEUE_OPAQUE;\r\n }\r\n /**\r\n * {@inheritDoc Drawable.isUnlit}\r\n */\r\n isUnlit() {\r\n return !this.material?.supportLighting();\r\n }\r\n /**\r\n * {@inheritDoc Drawable.needSceneColor}\r\n */\r\n needSceneColor() {\r\n return this.material?.needSceneColor() ?? false;\r\n }\r\n /**\r\n * {@inheritDoc Drawable.needSceneDepth}\r\n */\r\n needSceneDepth() {\r\n return this.material?.needSceneDepth() ?? false;\r\n }\r\n /** @internal */\r\n private updateMorphState() {\r\n if (this._morphInfo && this._morphDirty) {\r\n console.log(`jawOpen: ${this._morphInfo.data[20]}`);\r\n this._morphInfo.buffer!.get()!.bufferSubData(4 * 4, this._morphInfo.data, 4, this._morphInfo.data[3]);\r\n this._morphDirty = false;\r\n }\r\n }\r\n /** @internal */\r\n private updateSkeletonState() {\r\n if (this._suspendSkinning) {\r\n this.setBoneMatrices(null);\r\n this.setAnimatedBoundingBox(null);\r\n return;\r\n }\r\n const skeleton = this._skeletonName && this.findSkeletonById(this._skeletonName);\r\n if (skeleton) {\r\n this.setBoneMatrices(skeleton.jointTexture);\r\n skeleton.computeBoundingBox(this._skinnedBoundingInfo!, this.invWorldMatrix);\r\n this.setAnimatedBoundingBox(this._skinnedBoundingInfo!.boundingBox);\r\n } else {\r\n this.setBoneMatrices(null);\r\n this.setAnimatedBoundingBox(null);\r\n }\r\n if (this._skeletonName) {\r\n this.scene!.queueUpdateNode(this);\r\n }\r\n }\r\n /**\r\n * {@inheritDoc Drawable.draw}\r\n */\r\n draw(ctx: DrawContext, renderQueue: Nullable<RenderQueue>, hash?: string) {\r\n const material = this.material;\r\n const primitive = this.primitive;\r\n if (material && primitive) {\r\n if (this._useRenderBundle && !ctx.instanceData && hash) {\r\n if (\r\n this._primitiveChangeTag !== primitive.changeTag ||\r\n this._materialChangeTag !== material.changeTag\r\n ) {\r\n this._renderBundle = {};\r\n this._primitiveChangeTag = primitive.changeTag;\r\n this._materialChangeTag = material.changeTag;\r\n }\r\n const renderBundle = this._renderBundle![hash];\r\n if (!renderBundle) {\r\n ctx.device.beginCapture();\r\n this.bind(ctx, renderQueue);\r\n material.draw(primitive, ctx);\r\n this._renderBundle![hash] = ctx.device.endCapture();\r\n } else {\r\n ctx.device.executeRenderBundle(renderBundle);\r\n }\r\n } else {\r\n this.bind(ctx, renderQueue);\r\n material.draw(primitive, ctx);\r\n }\r\n }\r\n }\r\n /**\r\n * {@inheritDoc Drawable.getMaterial}\r\n */\r\n getMaterial() {\r\n return this.material;\r\n }\r\n /**\r\n * {@inheritDoc Drawable.getPrimitive}\r\n */\r\n getPrimitive() {\r\n return this.primitive;\r\n }\r\n /**\r\n * {@inheritDoc Drawable.getBoneMatrices}\r\n */\r\n getBoneMatrices() {\r\n return this._boneMatrices.get();\r\n }\r\n /**\r\n * {@inheritDoc Drawable.getNode}\r\n */\r\n getNode() {\r\n // mesh transform should be ignored when skinned\r\n return this;\r\n }\r\n /** @internal */\r\n computeBoundingVolume() {\r\n let bbox: Nullable<BoundingVolume>;\r\n if (this._animatedBoundingBox) {\r\n bbox = this._animatedBoundingBox;\r\n } else {\r\n bbox = this._primitive.get()?.getBoundingVolume() ?? null;\r\n }\r\n return bbox;\r\n }\r\n /** Disposes the mesh node */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._primitive.get()?.off('bv_changed', this._onBoundingboxChange, this);\r\n this._primitive.dispose();\r\n this._material.dispose();\r\n this._boneMatrices.dispose();\r\n this.setMorphData(null);\r\n this.setMorphInfo(null);\r\n this._renderBundle = null;\r\n RenderBundleWrapper.drawableChanged(this);\r\n }\r\n /** @internal */\r\n private _onBoundingboxChange() {\r\n this.invalidateBoundingVolume();\r\n }\r\n /** @internal */\r\n private static _defaultMaterial: Nullable<MeshMaterial> = null;\r\n /** @internal */\r\n private static _getDefaultMaterial() {\r\n if (!this._defaultMaterial) {\r\n this._defaultMaterial = new LambertMaterial();\r\n }\r\n return this._defaultMaterial;\r\n }\r\n}\r\n"],"names":["MeshBase","castObservable","applyMixins","GraphNode","mixinDrawable","Mesh","scene","primitive","material","_primitive","DRef","_material","_castShadow","_skinnedBoundingInfo","_animatedBoundingBox","_boneMatrices","_morphData","_morphInfo","_morphDirty","_instanceHash","_pickTarget","node","_batchable","getDevice","type","_getDefaultMaterial","_suspendSkinning","_skeletonName","_renderBundle","_useRenderBundle","_materialChangeTag","_primitiveChangeTag","_postUpdateCallbacks","Set","getInstanceId","_renderPass","worldMatrixDet","getInstanceUniforms","get","$instanceUniforms","getPickTarget","setPickTarget","label","skeletonName","name","updateSkeletonState","skinnedBoundingInfo","suspendSkinning","val","castShadow","b","prim","currentPrimitive","off","_onBoundingboxChange","set","on","_scene","id","instanceId","invalidateBoundingVolume","RenderBundleWrapper","drawableChanged","dispatchEvent","m","materialAttached","coreMaterial","isMesh","setAnimatedBoundingBox","bbox","getAnimatedBoundingBox","setBoneMatrices","matrices","setMorphData","data","texture","dispose","width","height","slice","tex","createTexture2D","mipmapping","samplerOptions","minFilter","magFilter","mipFilter","update","setSkinnedBoundingInfo","info","getMorphData","setMorphInfo","buffer","names","bufferType","PBStructTypeInfo","ShaderHelper","getMorphInfoUniformName","PBArrayTypeInfo","PBPrimitiveTypeInfo","PBPrimitiveType","F32VEC4","MORPH_WEIGHTS_VECTOR_COUNT","MORPH_ATTRIBUTE_VECTOR_COUNT","morphUniformBuffer","createStructuredBuffer","usage","getMorphInfo","getNumMorphTargets","getMorphTargetName","index","Object","keys","find","key","setMorphWeight","weight","undefined","queueUpdateNode","console","warn","getMorphWeight","updateMorphWeights","length","frameId","elapsedInSeconds","deltaInSeconds","updateMorphState","size","callback","addPostUpdateCallback","add","removePostUpdateCallback","delete","isBatchable","getQueueType","QUEUE_OPAQUE","isUnlit","supportLighting","needSceneColor","needSceneDepth","log","bufferSubData","skeleton","findSkeletonById","jointTexture","computeBoundingBox","invWorldMatrix","boundingBox","draw","ctx","renderQueue","hash","instanceData","changeTag","renderBundle","device","beginCapture","bind","endCapture","executeRenderBundle","getMaterial","getPrimitive","getBoneMatrices","getNode","computeBoundingVolume","getBoundingVolume","onDispose","_defaultMaterial","LambertMaterial"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwCA,MAAMA,QAAAA,GAAWC,cAAeC,CAAAA,WAAAA,CAAYC,SAAWC,EAAAA,aAAAA,CAAAA,CAAAA,EAAAA;AAKvD;;;IAIO,MAAMC,IAAaL,SAAAA,QAAAA,CAAAA;qBAExB,UAA6C;qBAE7C,SAA+C;qBAE/C,WAA+B;qBAE/B,oBAA6D;qBAE7D,oBAAsD;qBAEtD,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AA,EAAc,IAAI,CAACC,oBAAoB,EAAE,IAAI,CAAA;QACxE,IAAI,CAAC7C,UAAU,CAACmE,OAAO,EAAA;QACvB,IAAI,CAACjE,SAAS,CAACiE,OAAO,EAAA;QACtB,IAAI,CAAC7D,aAAa,CAAC6D,OAAO,EAAA;QAC1B,IAAI,CAACH,YAAY,CAAC,IAAA,CAAA;QAClB,IAAI,CAACkB,YAAY,CAAC,IAAA,CAAA;QAClB,IAAI,CAAC/D,aAAa,GAAG,IAAA;QACrBiC,mBAAoBC,CAAAA,eAAe,CAAC,IAAI,CAAA;AAC1C;qBAEA,oBAA+B,GAAA;AAC7B,QAAA,IAAI,CAACF,wBAAwB,EAAA;AAC/B;qBAEA,OAAe4G,gBAAAA,GAA2C,IAAK;qBAE/D,OAAe/I,mBAAsB,GAAA;AACnC,QAAA,IAAI,CAAC,IAAI,CAAC+I,gBAAgB,EAAE;YAC1B,IAAI,CAACA,gBAAgB,GAAG,IAAIC,eAAAA,EAAAA;AAC9B;QACA,OAAO,IAAI,CAACD,gBAAgB;AAC9B;AACF;;;;"}
@@ -0,0 +1,96 @@
1
+ import { applyMixins, DRef, Disposable } from '@zephyr3d/base';
2
+ import { mixinDrawable } from '../render/drawable_mixin.js';
3
+ import { QUEUE_OPAQUE } from '../values.js';
4
+
5
+ class MeshDrawableBase extends Disposable {
6
+ _node;
7
+ constructor(node){
8
+ super();
9
+ this._node = node;
10
+ }
11
+ getNode() {
12
+ return this._node;
13
+ }
14
+ }
15
+ class MeshDrawable extends applyMixins(MeshDrawableBase, mixinDrawable) {
16
+ _material;
17
+ _primitive;
18
+ constructor(node, material, primitive){
19
+ super(node);
20
+ this._material = new DRef(material);
21
+ this._primitive = new DRef(primitive);
22
+ }
23
+ get material() {
24
+ return this._material.get();
25
+ }
26
+ set material(mat) {
27
+ this._material.set(mat);
28
+ }
29
+ getMaterial() {
30
+ return this.material;
31
+ }
32
+ get primitive() {
33
+ return this._primitive.get();
34
+ }
35
+ set primitive(prim) {
36
+ this._primitive.set(prim);
37
+ }
38
+ getPrimitive() {
39
+ return this.primitive;
40
+ }
41
+ getPickTarget() {
42
+ return {
43
+ node: this.getNode()
44
+ };
45
+ }
46
+ getBoneMatrices() {
47
+ return null;
48
+ }
49
+ getMorphData() {
50
+ return null;
51
+ }
52
+ getMorphInfo() {
53
+ return null;
54
+ }
55
+ /**
56
+ * {@inheritDoc Drawable.getSortDistance}
57
+ */ getSortDistance(camera) {
58
+ const cameraWorldMatrix = camera.worldMatrix;
59
+ const objectWorldMatrix = this.getNode().worldMatrix;
60
+ const dx = cameraWorldMatrix.m03 - objectWorldMatrix.m03;
61
+ const dy = cameraWorldMatrix.m13 - objectWorldMatrix.m13;
62
+ const dz = cameraWorldMatrix.m23 - objectWorldMatrix.m23;
63
+ return dx * dx + dy * dy * dz * dz;
64
+ }
65
+ getQueueType() {
66
+ return this._material.get()?.getQueueType() ?? QUEUE_OPAQUE;
67
+ }
68
+ needSceneColor() {
69
+ return this._material.get()?.needSceneColor() ?? false;
70
+ }
71
+ needSceneDepth() {
72
+ return this._material.get()?.needSceneDepth() ?? false;
73
+ }
74
+ isUnlit() {
75
+ return !this._material.get()?.supportLighting();
76
+ }
77
+ isBatchable() {
78
+ return !!this._material.get() && this._material.get().isBatchable();
79
+ }
80
+ draw(ctx, renderQueue) {
81
+ const material = this.material;
82
+ const primitive = this.primitive;
83
+ if (material && primitive) {
84
+ this.bind(ctx, renderQueue);
85
+ material.draw(primitive, ctx);
86
+ }
87
+ }
88
+ onDispose() {
89
+ super.onDispose();
90
+ this._material.dispose();
91
+ this._primitive.dispose();
92
+ }
93
+ }
94
+
95
+ export { MeshDrawable, MeshDrawableBase };
96
+ //# sourceMappingURL=meshdrawable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"meshdrawable.js","sources":["../../src/scene/meshdrawable.ts"],"sourcesContent":["import type { Nullable } from '@zephyr3d/base';\r\nimport { applyMixins, Disposable, DRef } from '@zephyr3d/base';\r\nimport type { MeshMaterial } from '../material';\r\nimport type {\r\n BatchDrawable,\r\n Drawable,\r\n DrawContext,\r\n MorphData,\r\n MorphInfo,\r\n PickTarget,\r\n Primitive,\r\n RenderQueue\r\n} from '../render';\r\nimport type { SceneNode } from '.';\r\nimport { mixinDrawable } from '../render/drawable_mixin';\r\nimport type { Texture2D } from '@zephyr3d/device';\r\nimport type { Camera } from '../camera';\r\nimport { QUEUE_OPAQUE } from '../values';\r\n\r\nexport class MeshDrawableBase extends Disposable {\r\n private _node: SceneNode;\r\n constructor(node: SceneNode) {\r\n super();\r\n this._node = node;\r\n }\r\n getNode() {\r\n return this._node;\r\n }\r\n}\r\n\r\nexport class MeshDrawable<M extends MeshMaterial>\r\n extends applyMixins(MeshDrawableBase, mixinDrawable)\r\n implements Drawable\r\n{\r\n private _material: DRef<M>;\r\n private _primitive: DRef<Primitive>;\r\n constructor(node: SceneNode, material: M, primitive: Primitive) {\r\n super(node);\r\n this._material = new DRef(material);\r\n this._primitive = new DRef(primitive);\r\n }\r\n get material() {\r\n return this._material.get();\r\n }\r\n set material(mat) {\r\n this._material.set(mat);\r\n }\r\n getMaterial(): Nullable<MeshMaterial> {\r\n return this.material;\r\n }\r\n get primitive() {\r\n return this._primitive.get();\r\n }\r\n set primitive(prim) {\r\n this._primitive.set(prim);\r\n }\r\n getPrimitive(): Nullable<Primitive> {\r\n return this.primitive;\r\n }\r\n getPickTarget(): PickTarget {\r\n return { node: this.getNode() };\r\n }\r\n getBoneMatrices(): Nullable<Texture2D> {\r\n return null;\r\n }\r\n getMorphData(): Nullable<MorphData> {\r\n return null;\r\n }\r\n getMorphInfo(): Nullable<MorphInfo> {\r\n return null;\r\n }\r\n /**\r\n * {@inheritDoc Drawable.getSortDistance}\r\n */\r\n getSortDistance(camera: Camera) {\r\n const cameraWorldMatrix = camera.worldMatrix;\r\n const objectWorldMatrix = this.getNode().worldMatrix;\r\n const dx = cameraWorldMatrix.m03 - objectWorldMatrix.m03;\r\n const dy = cameraWorldMatrix.m13 - objectWorldMatrix.m13;\r\n const dz = cameraWorldMatrix.m23 - objectWorldMatrix.m23;\r\n return dx * dx + dy * dy * dz * dz;\r\n }\r\n getQueueType(): number {\r\n return this._material.get()?.getQueueType() ?? QUEUE_OPAQUE;\r\n }\r\n needSceneColor(): boolean {\r\n return this._material.get()?.needSceneColor() ?? false;\r\n }\r\n needSceneDepth(): boolean {\r\n return this._material.get()?.needSceneDepth() ?? false;\r\n }\r\n isUnlit(): boolean {\r\n return !this._material.get()?.supportLighting();\r\n }\r\n isBatchable(): this is BatchDrawable {\r\n return !!this._material.get() && this._material.get()!.isBatchable();\r\n }\r\n draw(ctx: DrawContext, renderQueue: Nullable<RenderQueue>): void {\r\n const material = this.material;\r\n const primitive = this.primitive;\r\n if (material && primitive) {\r\n this.bind(ctx, renderQueue);\r\n material.draw(primitive, ctx);\r\n }\r\n }\r\n protected onDispose() {\r\n super.onDispose();\r\n this._material.dispose();\r\n this._primitive.dispose();\r\n }\r\n}\r\n"],"names":["MeshDrawableBase","Disposable","_node","node","getNode","MeshDrawable","applyMixins","mixinDrawable","_material","_primitive","material","primitive","DRef","get","mat","set","getMaterial","prim","getPrimitive","getPickTarget","getBoneMatrices","getMorphData","getMorphInfo","getSortDistance","camera","cameraWorldMatrix","worldMatrix","objectWorldMatrix","dx","m03","dy","m13","dz","m23","getQueueType","QUEUE_OPAQUE","needSceneColor","needSceneDepth","isUnlit","supportLighting","isBatchable","draw","ctx","renderQueue","bind","onDispose","dispose"],"mappings":";;;;AAmBO,MAAMA,gBAAyBC,SAAAA,UAAAA,CAAAA;IAC5BC,KAAiB;AACzB,IAAA,WAAA,CAAYC,IAAe,CAAE;QAC3B,KAAK,EAAA;QACL,IAAI,CAACD,KAAK,GAAGC,IAAAA;AACf;IACAC,OAAU,GAAA;QACR,OAAO,IAAI,CAACF,KAAK;AACnB;AACF;AAEO,MAAMG,YACHC,SAAAA,WAAAA,CAAYN,gBAAkBO,EAAAA,aAAAA,CAAAA,CAAAA;IAG9BC,SAA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