@zephyr3d/scene 0.9.3 → 0.9.5
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.
- package/dist/animation/animationmask.js +224 -0
- package/dist/animation/animationmask.js.map +1 -0
- package/dist/animation/animationset.js +268 -67
- package/dist/animation/animationset.js.map +1 -1
- package/dist/animation/animationtrack.js.map +1 -1
- package/dist/animation/eulerrotationtrack.js +3 -0
- package/dist/animation/eulerrotationtrack.js.map +1 -1
- package/dist/animation/fixed_geometry_cache_track.js +7 -0
- package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
- package/dist/animation/ik_modifier.js.map +1 -1
- package/dist/animation/joint_dynamics/collision.js +6 -4
- package/dist/animation/joint_dynamics/collision.js.map +1 -1
- package/dist/animation/joint_dynamics/controller.js +390 -43
- package/dist/animation/joint_dynamics/controller.js.map +1 -1
- package/dist/animation/joint_dynamics/joint_dynamics_system.js +62 -3
- package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
- package/dist/animation/joint_dynamics/solver.js +4 -3
- package/dist/animation/joint_dynamics/solver.js.map +1 -1
- package/dist/animation/joint_dynamics/types.js.map +1 -1
- package/dist/animation/joint_dynamics_modifier.js +2 -0
- package/dist/animation/joint_dynamics_modifier.js.map +1 -1
- package/dist/animation/morphtarget.js +3 -72
- package/dist/animation/morphtarget.js.map +1 -1
- package/dist/animation/morphtrack.js +3 -0
- package/dist/animation/morphtrack.js.map +1 -1
- package/dist/animation/pca_geometry_cache_track.js +3 -0
- package/dist/animation/pca_geometry_cache_track.js.map +1 -1
- package/dist/animation/proptrack.js +3 -0
- package/dist/animation/proptrack.js.map +1 -1
- package/dist/animation/rotationtrack.js +3 -0
- package/dist/animation/rotationtrack.js.map +1 -1
- package/dist/animation/scaletrack.js +3 -0
- package/dist/animation/scaletrack.js.map +1 -1
- package/dist/animation/skeleton.js +254 -79
- package/dist/animation/skeleton.js.map +1 -1
- package/dist/animation/skeleton_modifier.js.map +1 -1
- package/dist/animation/spring/spring_particle.js +4 -4
- package/dist/animation/spring/spring_particle.js.map +1 -1
- package/dist/animation/spring_modifier.js.map +1 -1
- package/dist/animation/translationtrack.js +3 -0
- package/dist/animation/translationtrack.js.map +1 -1
- package/dist/app/engine.js +129 -17
- package/dist/app/engine.js.map +1 -1
- package/dist/app/scriptregistry.js +251 -80
- package/dist/app/scriptregistry.js.map +1 -1
- package/dist/asset/assetmanager.js +133 -102
- package/dist/asset/assetmanager.js.map +1 -1
- package/dist/asset/loaders/gltf/gltf_loader.js +18 -14
- package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
- package/dist/asset/loaders/loader.js +1 -6
- package/dist/asset/loaders/loader.js.map +1 -1
- package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -1
- package/dist/asset/model.js +1052 -183
- package/dist/asset/model.js.map +1 -1
- package/dist/avatar/wardrobe.js +474 -0
- package/dist/avatar/wardrobe.js.map +1 -0
- package/dist/index.d.ts +1810 -233
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/material/material.js +1 -1
- package/dist/material/material.js.map +1 -1
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +6 -3
- package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
- package/dist/material/mixins/pbr/common.js +72 -15
- package/dist/material/mixins/pbr/common.js.map +1 -1
- package/dist/material/msdf_text.js +180 -0
- package/dist/material/msdf_text.js.map +1 -0
- package/dist/material/msdf_text_sprite.js +64 -0
- package/dist/material/msdf_text_sprite.js.map +1 -0
- package/dist/material/pbrblueprint.js +21 -6
- package/dist/material/pbrblueprint.js.map +1 -1
- package/dist/material/shader/helper.js +277 -277
- package/dist/material/shader/helper.js.map +1 -1
- package/dist/material/sprite_sdf.js +106 -0
- package/dist/material/sprite_sdf.js.map +1 -0
- package/dist/posteffect/ssr.js +1 -0
- package/dist/posteffect/ssr.js.map +1 -1
- package/dist/render/abuffer_oit.js +1 -0
- package/dist/render/abuffer_oit.js.map +1 -1
- package/dist/render/cluster_light.js.map +1 -1
- package/dist/render/cull_visitor.js +28 -0
- package/dist/render/cull_visitor.js.map +1 -1
- package/dist/render/drawable.js.map +1 -1
- package/dist/render/drawable_mixin.js +1 -0
- package/dist/render/drawable_mixin.js.map +1 -1
- package/dist/render/envlight.js +54 -1
- package/dist/render/envlight.js.map +1 -1
- package/dist/render/fbm_wavegenerator.js +1 -0
- package/dist/render/fbm_wavegenerator.js.map +1 -1
- package/dist/render/gerstner_wavegenerator.js +1 -0
- package/dist/render/gerstner_wavegenerator.js.map +1 -1
- package/dist/render/globalbindgroup_allocator.js +1 -0
- package/dist/render/globalbindgroup_allocator.js.map +1 -1
- package/dist/render/render_queue.js +1 -0
- package/dist/render/render_queue.js.map +1 -1
- package/dist/render/sky.js +9 -0
- package/dist/render/sky.js.map +1 -1
- package/dist/scene/basesprite.js +1 -5
- package/dist/scene/basesprite.js.map +1 -1
- package/dist/scene/batchgroup.js +18 -8
- package/dist/scene/batchgroup.js.map +1 -1
- package/dist/scene/environment.js +16 -2
- package/dist/scene/environment.js.map +1 -1
- package/dist/scene/mesh.js +164 -102
- package/dist/scene/mesh.js.map +1 -1
- package/dist/scene/meshdrawable.js +96 -0
- package/dist/scene/meshdrawable.js.map +1 -0
- package/dist/scene/msdftext.js +341 -0
- package/dist/scene/msdftext.js.map +1 -0
- package/dist/scene/msdftextsprite.js +349 -0
- package/dist/scene/msdftextsprite.js.map +1 -0
- package/dist/scene/particlesys.js +1 -0
- package/dist/scene/particlesys.js.map +1 -1
- package/dist/scene/scene.js +2 -0
- package/dist/scene/scene.js.map +1 -1
- package/dist/scene/scene_node.js +437 -230
- package/dist/scene/scene_node.js.map +1 -1
- package/dist/scene/sdftextsprite.js +322 -0
- package/dist/scene/sdftextsprite.js.map +1 -0
- package/dist/scene/terrain-cm/grass.js +1 -0
- package/dist/scene/terrain-cm/grass.js.map +1 -1
- package/dist/scene/terrain-cm/grassmaterial.js +1 -0
- package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
- package/dist/scene/terrain-cm/terrain-cm.js +1 -0
- package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
- package/dist/scene/textsprite.js +120 -0
- package/dist/scene/textsprite.js.map +1 -0
- package/dist/scene/water.js +1 -0
- package/dist/scene/water.js.map +1 -1
- package/dist/shadow/shader.js +1 -0
- package/dist/shadow/shader.js.map +1 -1
- package/dist/text/font/font_asset.js +884 -0
- package/dist/text/font/font_asset.js.map +1 -0
- package/dist/text/font/sfnt_reader.js +43 -0
- package/dist/text/font/sfnt_reader.js.map +1 -0
- package/dist/text/msdf/generator.js +417 -0
- package/dist/text/msdf/generator.js.map +1 -0
- package/dist/text/msdf/shape.js +146 -0
- package/dist/text/msdf/shape.js.map +1 -0
- package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
- package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js +50 -0
- package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
- package/dist/text/runtime/text_layout.js +96 -0
- package/dist/text/runtime/text_layout.js.map +1 -0
- package/dist/utility/blueprint/material/inputs.js +188 -1
- package/dist/utility/blueprint/material/inputs.js.map +1 -1
- package/dist/utility/blueprint/material/ir.js +16 -1
- package/dist/utility/blueprint/material/ir.js.map +1 -1
- package/dist/utility/blueprint/material/pbr.js +32 -0
- package/dist/utility/blueprint/material/pbr.js.map +1 -1
- package/dist/utility/bounding_volume.js.map +1 -1
- package/dist/utility/pmrem.js +34 -8
- package/dist/utility/pmrem.js.map +1 -1
- package/dist/utility/serialization/manager.js +340 -283
- package/dist/utility/serialization/manager.js.map +1 -1
- package/dist/utility/serialization/scene/animation.js +702 -7
- package/dist/utility/serialization/scene/animation.js.map +1 -1
- package/dist/utility/serialization/scene/batch.js +2 -0
- package/dist/utility/serialization/scene/batch.js.map +1 -1
- package/dist/utility/serialization/scene/camera.js +2 -0
- package/dist/utility/serialization/scene/camera.js.map +1 -1
- package/dist/utility/serialization/scene/light.js +2 -0
- package/dist/utility/serialization/scene/light.js.map +1 -1
- package/dist/utility/serialization/scene/material.js +1 -0
- package/dist/utility/serialization/scene/material.js.map +1 -1
- package/dist/utility/serialization/scene/mesh.js +66 -4
- package/dist/utility/serialization/scene/mesh.js.map +1 -1
- package/dist/utility/serialization/scene/node.js +189 -8
- package/dist/utility/serialization/scene/node.js.map +1 -1
- package/dist/utility/serialization/scene/particle.js +2 -0
- package/dist/utility/serialization/scene/particle.js.map +1 -1
- package/dist/utility/serialization/scene/primitive.js +1 -0
- package/dist/utility/serialization/scene/primitive.js.map +1 -1
- package/dist/utility/serialization/scene/sprite.js +2 -0
- package/dist/utility/serialization/scene/sprite.js.map +1 -1
- package/dist/utility/serialization/scene/terrain.js +2 -0
- package/dist/utility/serialization/scene/terrain.js.map +1 -1
- package/dist/utility/serialization/scene/text.js +516 -0
- package/dist/utility/serialization/scene/text.js.map +1 -0
- package/dist/utility/serialization/scene/water.js +2 -0
- package/dist/utility/serialization/scene/water.js.map +1 -1
- package/dist/utility/serialization/types.js.map +1 -1
- package/dist/utility/textures/sheenlut.js +138 -0
- package/dist/utility/textures/sheenlut.js.map +1 -0
- package/dist/values.js +48 -48
- package/dist/values.js.map +1 -1
- package/package.json +3 -3
package/dist/scene/mesh.js.map
CHANGED
|
@@ -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,CAACE,WAAW,GAAG,IAAA;QACnB,IAAI,CAACC,oBAAoB,GAAG,IAAA;QAC5B,IAAI,CAACC,oBAAoB,GAAG,IAAA;QAC5B,IAAI,CAACC,aAAa,GAAG,IAAIL,IAAAA,EAAAA;QACzB,IAAI,CAACM,UAAU,GAAG,IAAA;QAClB,IAAI,CAACC,UAAU,GAAG,IAAA;QAClB,IAAI,CAACC,WAAW,GAAG,KAAA;QACnB,IAAI,CAACC,aAAa,GAAG,IAAA;QACrB,IAAI,CAACC,WAAW,GAAG;AAAEC,YAAAA,IAAAA,EAAM;AAAK,SAAA;AAChC,QAAA,IAAI,CAACC,UAAU,GAAGC,SAAAA,EAAAA,CAAYC,IAAI,KAAK,OAAA;QACvC,IAAI,CAACjB,SAAS,GAAGA,SAAa,IAAA,IAAA;AA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AAO,IAAI,CAAC7D,UAAU,CAAC+B,GAAG,IAAI+H,iBAAuB,EAAA,IAAA,IAAA;AACvD;QACA,OAAOjG,IAAAA;AACT;kCAEA,SAAsB,GAAA;AACpB,QAAA,KAAK,CAACkG,SAAAA,EAAAA;QACN,IAAI,CAAC/J,UAAU,CAAC+B,GAAG,EAAA,EAAIe,GAAI,CAAA,YAAA,EAAc,IAAI,CAACC,oBAAoB,EAAE,IAAI,CAAA;QACxE,IAAI,CAAC/C,UAAU,CAACoE,OAAO,EAAA;QACvB,IAAI,CAAClE,SAAS,CAACkE,OAAO,EAAA;QACtB,IAAI,CAAC9D,aAAa,CAAC8D,OAAO,EAAA;QAC1B,IAAI,CAACH,YAAY,CAAC,IAAA,CAAA;QAClB,IAAI,CAACkB,YAAY,CAAC,IAAA,CAAA;QAClB,IAAI,CAAChE,aAAa,GAAG,IAAA;QACrBmC,mBAAoBC,CAAAA,eAAe,CAAC,IAAI,CAAA;AAC1C;qBAEA,oBAA+B,GAAA;AAC7B,QAAA,IAAI,CAACF,wBAAwB,EAAA;AAC/B;qBAEA,OAAe2G,gBAAAA,GAA2C,IAAK;qBAE/D,OAAehJ,mBAAsB,GAAA;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 { BoundingBox, type BoundingVolume } 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\nimport { calculateMorphBoundingBox } from '../animation/morphtarget';\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\n/**\r\n * Bounding data used to update a mesh's local bounding box after morph target weights change.\r\n *\r\n * @public\r\n */\r\nexport interface MorphBoundingInfo {\r\n targetBoxes: BoundingBox[];\r\n originBox: BoundingBox;\r\n}\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 _skinBindingName: 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 _morphBoundingInfo: Nullable<MorphBoundingInfo>;\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._morphBoundingInfo = 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._skinBindingName = '';\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._skinBindingName;\r\n }\r\n set skeletonName(name) {\r\n this.skinBindingName = name;\r\n }\r\n get skinBindingName() {\r\n return this._skinBindingName;\r\n }\r\n set skinBindingName(name) {\r\n if (name !== this._skinBindingName) {\r\n this._skinBindingName = 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 morph target bounding data used to update the animated bounding box when weights change.\r\n * @param info - Morph target bounding data\r\n */\r\n setMorphBoundingInfo(info: Nullable<MorphBoundingInfo>) {\r\n this._morphBoundingInfo = info\r\n ? {\r\n targetBoxes: info.targetBoxes.map((box) => box.clone()),\r\n originBox: info.originBox.clone()\r\n }\r\n : null;\r\n this.updateMorphBoundingBox();\r\n }\r\n /**\r\n * Gets morph target bounding data.\r\n */\r\n getMorphBoundingInfo() {\r\n return this._morphBoundingInfo;\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.updateMorphBoundingBox();\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 * Get the index of the morph target by name\r\n * @param name - The name of the morph target\r\n * @returns The index of the morph target, or -1 if not found\r\n */\r\n getMorphTargetIndexByName(name: string): number {\r\n return this._morphInfo?.names?.[name] ?? -1;\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.getMorphTargetIndexByName(name);\r\n if (index >= 0) {\r\n this.setMorphWeightByIndex(index, weight);\r\n }\r\n }\r\n /**\r\n * Update morph target weight by index\r\n *\r\n * @param index - The index of the morph target\r\n * @param weight - The weight of the morph target\r\n */\r\n setMorphWeightByIndex(index: number, weight: number) {\r\n if (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.updateMorphBoundingBox();\r\n this.scene!.queueUpdateNode(this);\r\n }\r\n } else {\r\n console.warn(`Morph target index out of range: ${index}`);\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 weights\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.updateMorphBoundingBox();\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 updateMorphBoundingBox() {\r\n if (!this._morphInfo || !this._morphBoundingInfo) {\r\n return;\r\n }\r\n const numTargets = Math.min(this._morphInfo.data[3], this._morphBoundingInfo.targetBoxes.length);\r\n if (numTargets <= 0) {\r\n return;\r\n }\r\n const weights =\r\n this._morphInfo.data instanceof Float32Array\r\n ? this._morphInfo.data.subarray(4, 4 + numTargets)\r\n : new Float32Array(Array.from(this._morphInfo.data.subarray(4, 4 + numTargets)));\r\n const bbox = new BoundingBox();\r\n calculateMorphBoundingBox(bbox, this._morphBoundingInfo.targetBoxes, weights, numTargets);\r\n bbox.minPoint.addBy(this._morphBoundingInfo.originBox.minPoint);\r\n bbox.maxPoint.addBy(this._morphBoundingInfo.originBox.maxPoint);\r\n this.setAnimatedBoundingBox(bbox);\r\n }\r\n /** @internal */\r\n private updateMorphState() {\r\n if (this._morphInfo && this._morphDirty) {\r\n this._morphInfo.buffer!.get()!.bufferSubData(4 * 4, this._morphInfo.data, 4, this._morphInfo.data[3]);\r\n this.updateMorphBoundingBox();\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 binding = this._skinBindingName && this.findSkinBindingById(this._skinBindingName);\r\n if (binding) {\r\n this.setBoneMatrices(binding.jointTexture);\r\n binding.computeBoundingBox(this._skinnedBoundingInfo!, this.invWorldMatrix);\r\n this.setAnimatedBoundingBox(this._skinnedBoundingInfo!.boundingBox);\r\n } else {\r\n this.setBoneMatrices(null);\r\n if (!this._morphInfo || !this._morphBoundingInfo) {\r\n this.setAnimatedBoundingBox(null);\r\n }\r\n }\r\n if (this._skinBindingName) {\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.setMorphBoundingInfo(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","_morphBoundingInfo","_morphDirty","_instanceHash","_pickTarget","node","_batchable","getDevice","type","_getDefaultMaterial","_suspendSkinning","_skinBindingName","_renderBundle","_useRenderBundle","_materialChangeTag","_primitiveChangeTag","_postUpdateCallbacks","Set","getInstanceId","_renderPass","worldMatrixDet","getInstanceUniforms","get","$instanceUniforms","getPickTarget","setPickTarget","label","skeletonName","name","skinBindingName","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","setMorphBoundingInfo","info","targetBoxes","map","box","clone","originBox","updateMorphBoundingBox","getMorphBoundingInfo","setBoneMatrices","matrices","setMorphData","data","texture","dispose","width","height","slice","tex","createTexture2D","mipmapping","samplerOptions","minFilter","magFilter","mipFilter","update","setSkinnedBoundingInfo","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","getMorphTargetIndexByName","setMorphWeight","weight","setMorphWeightByIndex","queueUpdateNode","console","warn","getMorphWeight","undefined","updateMorphWeights","length","frameId","elapsedInSeconds","deltaInSeconds","updateMorphState","size","callback","addPostUpdateCallback","add","removePostUpdateCallback","delete","isBatchable","getQueueType","QUEUE_OPAQUE","isUnlit","supportLighting","needSceneColor","needSceneDepth","numTargets","Math","min","weights","Float32Array","subarray","Array","from","BoundingBox","calculateMorphBoundingBox","minPoint","addBy","maxPoint","bufferSubData","binding","findSkinBindingById","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":";;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,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;qBA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C,aAAa,GAAG,IAAA;QACrBkC,mBAAoBC,CAAAA,eAAe,CAAC,IAAI,CAAA;AAC1C;qBAEA,oBAA+B,GAAA;AAC7B,QAAA,IAAI,CAACF,wBAAwB,EAAA;AAC/B;qBAEA,OAAekI,gBAAAA,GAA2C,IAAK;qBAE/D,OAAetK,mBAAsB,GAAA;AACnC,QAAA,IAAI,CAAC,IAAI,CAACsK,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,SAAmB;IACnBC,UAA4B;AACpC,IAAA,WAAA,CAAYN,IAAe,EAAEO,QAAW,EAAEC,SAAoB,CAAE;AAC9D,QAAA,KAAK,CAACR,IAAAA,CAAAA;AACN,QAAA,IAAI,CAACK,SAAS,GAAG,IAAII,IAAKF,CAAAA,QAAAA,CAAAA;AAC1B,QAAA,IAAI,CAACD,UAAU,GAAG,IAAIG,IAAKD,CAAAA,SAAAA,CAAAA;AAC7B;AACA,IAAA,IAAID,QAAW,GAAA;AACb,QAAA,OAAO,IAAI,CAACF,SAAS,CAACK,GAAG,EAAA;AAC3B;IACA,IAAIH,QAAAA,CAASI,GAAG,EAAE;AAChB,QAAA,IAAI,CAACN,SAAS,CAACO,GAAG,CAACD,GAAAA,CAAAA;AACrB;IACAE,WAAsC,GAAA;QACpC,OAAO,IAAI,CAACN,QAAQ;AACtB;AACA,IAAA,IAAIC,SAAY,GAAA;AACd,QAAA,OAAO,IAAI,CAACF,UAAU,CAACI,GAAG,EAAA;AAC5B;IACA,IAAIF,SAAAA,CAAUM,IAAI,EAAE;AAClB,QAAA,IAAI,CAACR,UAAU,CAACM,GAAG,CAACE,IAAAA,CAAAA;AACtB;IACAC,YAAoC,GAAA;QAClC,OAAO,IAAI,CAACP,SAAS;AACvB;IACAQ,aAA4B,GAAA;QAC1B,OAAO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,SAAS,CAACK,GAAG,GAAI2B,WAAW,EAAA;AACpE;IACAC,IAAKC,CAAAA,GAAgB,EAAEC,WAAkC,EAAQ;QAC/D,MAAMjC,QAAAA,GAAW,IAAI,CAACA,QAAQ;QAC9B,MAAMC,SAAAA,GAAY,IAAI,CAACA,SAAS;AAChC,QAAA,IAAID,YAAYC,SAAW,EAAA;YACzB,IAAI,CAACiC,IAAI,CAACF,GAAKC,EAAAA,WAAAA,CAAAA;YACfjC,QAAS+B,CAAAA,IAAI,CAAC9B,SAAW+B,EAAAA,GAAAA,CAAAA;AAC3B;AACF;IACUG,SAAY,GAAA;AACpB,QAAA,KAAK,CAACA,SAAAA,EAAAA;QACN,IAAI,CAACrC,SAAS,CAACsC,OAAO,EAAA;QACtB,IAAI,CAACrC,UAAU,CAACqC,OAAO,EAAA;AACzB;AACF;;;;"}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { Vector2, Vector3 } from '@zephyr3d/base';
|
|
2
|
+
import { BoundingBox } from '../utility/bounding_volume.js';
|
|
3
|
+
import { getEngine } from '../app/api.js';
|
|
4
|
+
import '../values.js';
|
|
5
|
+
import '../render/render_queue.js';
|
|
6
|
+
import { Primitive } from '../render/primitive.js';
|
|
7
|
+
import '@zephyr3d/device';
|
|
8
|
+
import '../material/shader/helper.js';
|
|
9
|
+
import '../material/lambert.js';
|
|
10
|
+
import '../material/blinn.js';
|
|
11
|
+
import '../material/unlit.js';
|
|
12
|
+
import '../material/particle.js';
|
|
13
|
+
import '../material/meshmaterial.js';
|
|
14
|
+
import '../material/grassmaterial.js';
|
|
15
|
+
import '../material/terrain-cm.js';
|
|
16
|
+
import '../material/pbrmr.js';
|
|
17
|
+
import '../material/pbrsg.js';
|
|
18
|
+
import '../material/pbrblueprint.js';
|
|
19
|
+
import '../material/sprite.js';
|
|
20
|
+
import '../material/sprite_std.js';
|
|
21
|
+
import { MSDFTextMaterial } from '../material/msdf_text.js';
|
|
22
|
+
import '../utility/blueprint/material/texture.js';
|
|
23
|
+
import '../render/rendergraph/forward_plus_builder.js';
|
|
24
|
+
import '../render/sky.js';
|
|
25
|
+
import '../render/clipmap.js';
|
|
26
|
+
import '../shaders/atmosphere.js';
|
|
27
|
+
import { layoutText } from '../text/runtime/text_layout.js';
|
|
28
|
+
import { MeshDrawable } from './meshdrawable.js';
|
|
29
|
+
import { GraphNode } from './graph_node.js';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Billboard MSDF text node.
|
|
33
|
+
*
|
|
34
|
+
* @public
|
|
35
|
+
*/ class MSDFText extends GraphNode {
|
|
36
|
+
_fontAsset;
|
|
37
|
+
_atlas;
|
|
38
|
+
_castShadow;
|
|
39
|
+
_text;
|
|
40
|
+
_fontSize;
|
|
41
|
+
_maxWidth;
|
|
42
|
+
_textAlign;
|
|
43
|
+
_anchor;
|
|
44
|
+
_color;
|
|
45
|
+
_outlineWidth;
|
|
46
|
+
_outlineColor;
|
|
47
|
+
_pageBatches;
|
|
48
|
+
constructor(scene){
|
|
49
|
+
super(scene);
|
|
50
|
+
this._castShadow = false;
|
|
51
|
+
this._fontAsset = null;
|
|
52
|
+
this._atlas = null;
|
|
53
|
+
this._text = '';
|
|
54
|
+
this._fontSize = 32;
|
|
55
|
+
this._maxWidth = 0;
|
|
56
|
+
this._textAlign = 'left';
|
|
57
|
+
this._anchor = new Vector2(0.5, 0.5);
|
|
58
|
+
this._color = new Vector3(1, 1, 1);
|
|
59
|
+
this._outlineWidth = 0;
|
|
60
|
+
this._outlineColor = new Vector3(0, 0, 0);
|
|
61
|
+
this._pageBatches = [];
|
|
62
|
+
this.scene.queueUpdateNode(this);
|
|
63
|
+
}
|
|
64
|
+
get castShadow() {
|
|
65
|
+
return this._castShadow;
|
|
66
|
+
}
|
|
67
|
+
set castShadow(value) {
|
|
68
|
+
this._castShadow = value;
|
|
69
|
+
}
|
|
70
|
+
get fontAsset() {
|
|
71
|
+
return this._fontAsset;
|
|
72
|
+
}
|
|
73
|
+
set fontAsset(font) {
|
|
74
|
+
if (this._fontAsset !== font) {
|
|
75
|
+
this._fontAsset = font;
|
|
76
|
+
this._atlas = font ? getEngine().msdfTextAtlasManager.getAtlas(font) : null;
|
|
77
|
+
this.scene.queueUpdateNode(this);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
get text() {
|
|
81
|
+
return this._text;
|
|
82
|
+
}
|
|
83
|
+
set text(value) {
|
|
84
|
+
if (this._text !== value) {
|
|
85
|
+
this._text = value ?? '';
|
|
86
|
+
this.scene.queueUpdateNode(this);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
get fontSize() {
|
|
90
|
+
return this._fontSize;
|
|
91
|
+
}
|
|
92
|
+
set fontSize(value) {
|
|
93
|
+
if (this._fontSize !== value) {
|
|
94
|
+
this._fontSize = Math.max(1, value);
|
|
95
|
+
this.scene.queueUpdateNode(this);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
get maxWidth() {
|
|
99
|
+
return this._maxWidth;
|
|
100
|
+
}
|
|
101
|
+
set maxWidth(value) {
|
|
102
|
+
if (this._maxWidth !== value) {
|
|
103
|
+
this._maxWidth = Math.max(0, value);
|
|
104
|
+
this.scene.queueUpdateNode(this);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
get textAlign() {
|
|
108
|
+
return this._textAlign;
|
|
109
|
+
}
|
|
110
|
+
set textAlign(value) {
|
|
111
|
+
if (this._textAlign !== value) {
|
|
112
|
+
this._textAlign = value;
|
|
113
|
+
this.scene.queueUpdateNode(this);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
get anchorX() {
|
|
117
|
+
return this._anchor.x;
|
|
118
|
+
}
|
|
119
|
+
set anchorX(value) {
|
|
120
|
+
if (this._anchor.x !== value) {
|
|
121
|
+
this._anchor.x = value;
|
|
122
|
+
this.scene.queueUpdateNode(this);
|
|
123
|
+
this.invalidateWorldBoundingVolume(false);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
get anchorY() {
|
|
127
|
+
return this._anchor.y;
|
|
128
|
+
}
|
|
129
|
+
set anchorY(value) {
|
|
130
|
+
if (this._anchor.y !== value) {
|
|
131
|
+
this._anchor.y = value;
|
|
132
|
+
this.scene.queueUpdateNode(this);
|
|
133
|
+
this.invalidateWorldBoundingVolume(false);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
get anchor() {
|
|
137
|
+
return this._anchor;
|
|
138
|
+
}
|
|
139
|
+
set anchor(value) {
|
|
140
|
+
if (!this._anchor.equalsTo(value)) {
|
|
141
|
+
this._anchor.set(value);
|
|
142
|
+
this.scene.queueUpdateNode(this);
|
|
143
|
+
this.invalidateWorldBoundingVolume(false);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
get textColor() {
|
|
147
|
+
return this._color;
|
|
148
|
+
}
|
|
149
|
+
set textColor(value) {
|
|
150
|
+
if (!this._color.equalsTo(value)) {
|
|
151
|
+
this._color.set(value);
|
|
152
|
+
for (const batch of this._pageBatches){
|
|
153
|
+
batch.material.textColor = value;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
get outlineWidth() {
|
|
158
|
+
return this._outlineWidth;
|
|
159
|
+
}
|
|
160
|
+
set outlineWidth(value) {
|
|
161
|
+
if (this._outlineWidth !== value) {
|
|
162
|
+
this._outlineWidth = value;
|
|
163
|
+
for (const batch of this._pageBatches){
|
|
164
|
+
batch.material.outlineWidth = value;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
get outlineColor() {
|
|
169
|
+
return this._outlineColor;
|
|
170
|
+
}
|
|
171
|
+
set outlineColor(value) {
|
|
172
|
+
if (!this._outlineColor.equalsTo(value)) {
|
|
173
|
+
this._outlineColor.set(value);
|
|
174
|
+
for (const batch of this._pageBatches){
|
|
175
|
+
batch.material.outlineColor = value;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
get batches() {
|
|
180
|
+
return this._pageBatches;
|
|
181
|
+
}
|
|
182
|
+
update() {
|
|
183
|
+
if (!this._fontAsset || !this._atlas || !this._text) {
|
|
184
|
+
this.disposePageBatches();
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const layout = layoutText(this._atlas, this._fontAsset, this._text, this._fontSize, this._maxWidth);
|
|
188
|
+
const bv = new BoundingBox();
|
|
189
|
+
bv.beginExtend();
|
|
190
|
+
const geometries = buildPagedSpriteGeometry(layout, this._fontAsset.metrics.unitsPerEm, this._fontAsset.metrics.ascent, this._fontSize, this._anchor, this._textAlign, bv);
|
|
191
|
+
const pageIndices = [
|
|
192
|
+
...geometries.pages.keys()
|
|
193
|
+
].sort((a, b)=>a - b);
|
|
194
|
+
for(let i = 0; i < pageIndices.length; i++){
|
|
195
|
+
const pageIndex = pageIndices[i];
|
|
196
|
+
const geometry = geometries.pages.get(pageIndex);
|
|
197
|
+
const batch = this.ensurePageBatch(i);
|
|
198
|
+
updatePrimitiveGeometry(batch.primitive, geometry.positions, geometry.uvs, geometry.indices);
|
|
199
|
+
batch.primitive.setBoundingVolume(bv);
|
|
200
|
+
batch.material.atlasTexture = this._atlas.getAtlasTexture(pageIndex) ?? null;
|
|
201
|
+
batch.material.textColor = this._color;
|
|
202
|
+
batch.material.distanceRange = this._atlas.distanceRange;
|
|
203
|
+
batch.material.outlineWidth = this._outlineWidth;
|
|
204
|
+
batch.material.outlineColor = this._outlineColor;
|
|
205
|
+
}
|
|
206
|
+
this.disposePageBatches(pageIndices.length);
|
|
207
|
+
this.setBoundingVolume(bv);
|
|
208
|
+
}
|
|
209
|
+
isMSDFText() {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
onDispose() {
|
|
213
|
+
this._atlas = null;
|
|
214
|
+
this.disposePageBatches();
|
|
215
|
+
super.onDispose();
|
|
216
|
+
}
|
|
217
|
+
ensurePageBatch(index) {
|
|
218
|
+
let batch = this._pageBatches[index];
|
|
219
|
+
if (!batch) {
|
|
220
|
+
batch = new MeshDrawable(this, new MSDFTextMaterial(), new Primitive());
|
|
221
|
+
this._pageBatches[index] = batch;
|
|
222
|
+
}
|
|
223
|
+
return batch;
|
|
224
|
+
}
|
|
225
|
+
disposePageBatches(fromIndex = 0) {
|
|
226
|
+
for(let i = this._pageBatches.length - 1; i >= fromIndex; i--){
|
|
227
|
+
this._pageBatches[i].dispose();
|
|
228
|
+
this._pageBatches.splice(i, 1);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
function buildPagedSpriteGeometry(layout, unitsPerEm, ascent, fontSize, anchor, textAlign, bv) {
|
|
233
|
+
const scale = fontSize / unitsPerEm;
|
|
234
|
+
const top = ascent * scale;
|
|
235
|
+
const bottom = top - layout.height;
|
|
236
|
+
const anchorOffsetX = layout.boxWidth * anchor.x;
|
|
237
|
+
const anchorOffsetY = bottom + layout.height * anchor.y;
|
|
238
|
+
const lineOffsets = layout.lines.map((line)=>{
|
|
239
|
+
const gap = Math.max(layout.boxWidth - line.width, 0);
|
|
240
|
+
switch(textAlign){
|
|
241
|
+
case 'center':
|
|
242
|
+
return gap * 0.5;
|
|
243
|
+
case 'right':
|
|
244
|
+
return gap;
|
|
245
|
+
default:
|
|
246
|
+
return 0;
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
let minX = -anchorOffsetX;
|
|
250
|
+
let maxX = layout.boxWidth - anchorOffsetX;
|
|
251
|
+
let minY = bottom - anchorOffsetY;
|
|
252
|
+
let maxY = top - anchorOffsetY;
|
|
253
|
+
const pageGlyphs = new Map();
|
|
254
|
+
for (const glyph of layout.glyphs){
|
|
255
|
+
let list = pageGlyphs.get(glyph.atlasGlyph.atlasIndex);
|
|
256
|
+
if (!list) {
|
|
257
|
+
list = [];
|
|
258
|
+
pageGlyphs.set(glyph.atlasGlyph.atlasIndex, list);
|
|
259
|
+
}
|
|
260
|
+
list.push(glyph);
|
|
261
|
+
}
|
|
262
|
+
const pages = new Map();
|
|
263
|
+
for (const [atlasIndex, glyphs] of pageGlyphs){
|
|
264
|
+
const glyphCount = glyphs.length;
|
|
265
|
+
const positions = new Float32Array(glyphCount * 4 * 3);
|
|
266
|
+
const uvs = new Float32Array(glyphCount * 4 * 2);
|
|
267
|
+
const indices = glyphCount * 4 > 65535 ? new Uint32Array(glyphCount * 6) : new Uint16Array(glyphCount * 6);
|
|
268
|
+
for(let i = 0; i < glyphCount; i++){
|
|
269
|
+
const glyph = glyphs[i];
|
|
270
|
+
const atlasGlyph = glyph.atlasGlyph;
|
|
271
|
+
const lineOffsetX = lineOffsets[glyph.lineIndex] ?? 0;
|
|
272
|
+
const x0 = lineOffsetX + glyph.x + glyph.xOffset + atlasGlyph.planeLeft * scale - anchorOffsetX;
|
|
273
|
+
const y0 = -glyph.y + atlasGlyph.planeTop * scale - anchorOffsetY;
|
|
274
|
+
const x1 = lineOffsetX + glyph.x + glyph.xOffset + atlasGlyph.planeRight * scale - anchorOffsetX;
|
|
275
|
+
const y1 = -glyph.y + atlasGlyph.planeBottom * scale - anchorOffsetY;
|
|
276
|
+
minX = Math.min(minX, x0, x1);
|
|
277
|
+
maxX = Math.max(maxX, x0, x1);
|
|
278
|
+
minY = Math.min(minY, y0, y1);
|
|
279
|
+
maxY = Math.max(maxY, y0, y1);
|
|
280
|
+
const p = i * 12;
|
|
281
|
+
positions[p + 0] = x0;
|
|
282
|
+
positions[p + 1] = y0;
|
|
283
|
+
positions[p + 2] = 0;
|
|
284
|
+
positions[p + 3] = x1;
|
|
285
|
+
positions[p + 4] = y0;
|
|
286
|
+
positions[p + 5] = 0;
|
|
287
|
+
positions[p + 6] = x0;
|
|
288
|
+
positions[p + 7] = y1;
|
|
289
|
+
positions[p + 8] = 0;
|
|
290
|
+
positions[p + 9] = x1;
|
|
291
|
+
positions[p + 10] = y1;
|
|
292
|
+
positions[p + 11] = 0;
|
|
293
|
+
for(let k = 0; k < 4; k++){
|
|
294
|
+
bv.extend3(positions[p + k * 3], positions[p + k * 3 + 1], positions[p + k * 3 + 2]);
|
|
295
|
+
}
|
|
296
|
+
const t = i * 8;
|
|
297
|
+
uvs[t + 0] = atlasGlyph.uMin;
|
|
298
|
+
uvs[t + 1] = atlasGlyph.vMin;
|
|
299
|
+
uvs[t + 2] = atlasGlyph.uMax;
|
|
300
|
+
uvs[t + 3] = atlasGlyph.vMin;
|
|
301
|
+
uvs[t + 4] = atlasGlyph.uMin;
|
|
302
|
+
uvs[t + 5] = atlasGlyph.vMax;
|
|
303
|
+
uvs[t + 6] = atlasGlyph.uMax;
|
|
304
|
+
uvs[t + 7] = atlasGlyph.vMax;
|
|
305
|
+
const baseVertex = i * 4;
|
|
306
|
+
const indexOffset = i * 6;
|
|
307
|
+
indices[indexOffset + 0] = baseVertex + 0;
|
|
308
|
+
indices[indexOffset + 1] = baseVertex + 1;
|
|
309
|
+
indices[indexOffset + 2] = baseVertex + 2;
|
|
310
|
+
indices[indexOffset + 3] = baseVertex + 2;
|
|
311
|
+
indices[indexOffset + 4] = baseVertex + 1;
|
|
312
|
+
indices[indexOffset + 5] = baseVertex + 3;
|
|
313
|
+
}
|
|
314
|
+
pages.set(atlasIndex, {
|
|
315
|
+
positions,
|
|
316
|
+
uvs,
|
|
317
|
+
indices
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
return {
|
|
321
|
+
pages,
|
|
322
|
+
bounds: {
|
|
323
|
+
minX,
|
|
324
|
+
minY,
|
|
325
|
+
maxX,
|
|
326
|
+
maxY
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function updatePrimitiveGeometry(primitive, positions, uvs, indices) {
|
|
331
|
+
primitive.removeVertexBuffer('position');
|
|
332
|
+
primitive.removeVertexBuffer('texCoord0');
|
|
333
|
+
primitive.setIndexBuffer(null);
|
|
334
|
+
primitive.createAndSetVertexBuffer('position_f32x3', positions);
|
|
335
|
+
primitive.createAndSetVertexBuffer('tex0_f32x2', uvs);
|
|
336
|
+
primitive.createAndSetIndexBuffer(indices);
|
|
337
|
+
primitive.indexCount = indices.length;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export { MSDFText };
|
|
341
|
+
//# sourceMappingURL=msdftext.js.map
|