@babylonjs/core 7.35.1 → 7.36.0
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/Engines/Extensions/engine.multiRender.d.ts +11 -0
- package/Engines/Extensions/engine.multiRender.js +71 -32
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.prefilteredCubeTexture.js +3 -2
- package/Engines/Extensions/engine.prefilteredCubeTexture.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +1 -13
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +2 -0
- package/Engines/WebGL/webGLRenderTargetWrapper.js +37 -7
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +11 -0
- package/Engines/WebGPU/Extensions/engine.multiRender.js +30 -11
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +2 -5
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +3 -2
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.d.ts +3 -1
- package/Engines/WebGPU/webgpuHardwareTexture.js +5 -4
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +2 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.d.ts +11 -0
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/renderTargetWrapper.d.ts +33 -1
- package/Engines/renderTargetWrapper.js +64 -4
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.d.ts +13 -1
- package/Engines/thinEngine.js +115 -24
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +2 -0
- package/Engines/thinWebGPUEngine.js +7 -0
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +12 -3
- package/Engines/webgpuEngine.js +39 -9
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +8 -0
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +22 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.d.ts +4 -9
- package/FrameGraph/Node/Blocks/inputBlock.js +15 -25
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js +10 -2
- package/FrameGraph/Node/nodeRenderGraphBlockConnectionPoint.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +10 -10
- package/FrameGraph/Passes/renderPass.js +10 -10
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +10 -5
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js +29 -14
- package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js +4 -0
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldMergeTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +11 -6
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +30 -13
- package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +4 -6
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/cullObjectsTask.d.ts +1 -1
- package/FrameGraph/Tasks/Rendering/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +3 -3
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +33 -32
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +4 -2
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +8 -12
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +13 -18
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +15 -2
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +17 -4
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +2 -2
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/generateMipMapsTask.js +3 -3
- package/FrameGraph/Tasks/Texture/generateMipMapsTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +11 -74
- package/FrameGraph/frameGraph.js +12 -126
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +17 -8
- package/FrameGraph/frameGraphRenderContext.js +55 -43
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderTarget.d.ts +16 -0
- package/FrameGraph/frameGraphRenderTarget.js +67 -0
- package/FrameGraph/frameGraphRenderTarget.js.map +1 -0
- package/FrameGraph/frameGraphTask.d.ts +4 -3
- package/FrameGraph/frameGraphTask.js +41 -8
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +130 -22
- package/FrameGraph/frameGraphTextureManager.js +312 -130
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/frameGraphTypes.d.ts +28 -13
- package/FrameGraph/frameGraphTypes.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +3 -2
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/conditionalBlock.d.ts +2 -0
- package/Materials/Node/Blocks/conditionalBlock.js +13 -0
- package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.js +4 -1
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js +12 -4
- package/Materials/Node/nodeMaterialBlockConnectionPoint.js.map +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.js +14 -4
- package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +20 -0
- package/Materials/Textures/internalTexture.js +48 -0
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.d.ts +5 -0
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/textureCreationOptions.d.ts +6 -6
- package/Materials/Textures/textureCreationOptions.js.map +1 -1
- package/Materials/drawWrapper.js +4 -0
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.js +2 -2
- package/Materials/effect.js.map +1 -1
- package/Materials/material.d.ts +2 -2
- package/Materials/material.js +5 -5
- package/Materials/material.js.map +1 -1
- package/Maths/math.color.d.ts +16 -0
- package/Maths/math.color.js +16 -0
- package/Maths/math.color.js.map +1 -1
- package/Maths/math.vector.d.ts +32 -0
- package/Maths/math.vector.js +32 -0
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Compression/dracoCompression.d.ts +3 -1
- package/Meshes/Compression/dracoCompression.js +5 -2
- package/Meshes/Compression/dracoCompression.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/rotationXBlock.d.ts +0 -1
- package/Meshes/Node/Blocks/Matrices/rotationXBlock.js +1 -9
- package/Meshes/Node/Blocks/Matrices/rotationXBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/rotationYBlock.d.ts +0 -1
- package/Meshes/Node/Blocks/Matrices/rotationYBlock.js +1 -9
- package/Meshes/Node/Blocks/Matrices/rotationYBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/rotationZBlock.d.ts +0 -1
- package/Meshes/Node/Blocks/Matrices/rotationZBlock.js +1 -9
- package/Meshes/Node/Blocks/Matrices/rotationZBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/latticeBlock.js +3 -1
- package/Meshes/Node/Blocks/Set/latticeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/conditionBlock.d.ts +2 -0
- package/Meshes/Node/Blocks/conditionBlock.js +15 -0
- package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryClampBlock.d.ts +4 -4
- package/Meshes/Node/Blocks/geometryClampBlock.js +16 -25
- package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryLerpBlock.js +2 -2
- package/Meshes/Node/Blocks/geometryLerpBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryNLerpBlock.js +2 -2
- package/Meshes/Node/Blocks/geometryNLerpBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryReplaceColorBlock.js +2 -2
- package/Meshes/Node/Blocks/geometryReplaceColorBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryRotate2dBlock.js +2 -2
- package/Meshes/Node/Blocks/geometryRotate2dBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometrySmoothStepBlock.js +3 -3
- package/Meshes/Node/Blocks/geometrySmoothStepBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryStepBlock.js +2 -2
- package/Meshes/Node/Blocks/geometryStepBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometry.js +1 -1
- package/Meshes/Node/nodeGeometry.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlock.d.ts +3 -1
- package/Meshes/Node/nodeGeometryBlock.js +2 -1
- package/Meshes/Node/nodeGeometryBlock.js.map +1 -1
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js +10 -2
- package/Meshes/Node/nodeGeometryBlockConnectionPoint.js.map +1 -1
- package/Meshes/abstractMesh.js +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/lattice.material.d.ts +1 -1
- package/Meshes/lattice.material.js +3 -3
- package/Meshes/lattice.material.js.map +1 -1
- package/Misc/observable.d.ts +3 -1
- package/Misc/observable.js +7 -2
- package/Misc/observable.js.map +1 -1
- package/ShadersWGSL/glowMapGeneration.fragment.js +4 -3
- package/ShadersWGSL/glowMapGeneration.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +4 -3
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +6 -6
- package/scene.js.map +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { BoundingInfo } from "../../Culling/boundingInfo";
|
|
1
2
|
import { AutoReleaseWorkerPool } from "../../Misc/workerPool";
|
|
3
|
+
import type { Nullable } from "../../types";
|
|
2
4
|
import type { IDisposable, Scene } from "../../scene";
|
|
3
5
|
import { Geometry } from "../geometry";
|
|
4
6
|
import { VertexData } from "../mesh.vertexData";
|
|
@@ -170,7 +172,7 @@ export declare class DracoCompression implements IDisposable {
|
|
|
170
172
|
[kind: string]: number;
|
|
171
173
|
}, gltfNormalizedOverride: {
|
|
172
174
|
[kind: string]: boolean;
|
|
173
|
-
}): Promise<Geometry>;
|
|
175
|
+
}, boundingInfo: Nullable<BoundingInfo>): Promise<Geometry>;
|
|
174
176
|
/**
|
|
175
177
|
* Decode Draco compressed mesh data to Babylon vertex data.
|
|
176
178
|
* @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
1
|
import { Tools } from "../../Misc/tools.js";
|
|
3
2
|
import { AutoReleaseWorkerPool } from "../../Misc/workerPool.js";
|
|
4
3
|
import { Geometry } from "../geometry.js";
|
|
@@ -273,9 +272,13 @@ export class DracoCompression {
|
|
|
273
272
|
return geometry;
|
|
274
273
|
}
|
|
275
274
|
/** @internal */
|
|
276
|
-
async _decodeMeshToGeometryForGltfAsync(name, scene, data, attributes, gltfNormalizedOverride) {
|
|
275
|
+
async _decodeMeshToGeometryForGltfAsync(name, scene, data, attributes, gltfNormalizedOverride, boundingInfo) {
|
|
277
276
|
const meshData = await this.decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride);
|
|
278
277
|
const geometry = new Geometry(name, scene);
|
|
278
|
+
if (boundingInfo) {
|
|
279
|
+
geometry._boundingInfo = boundingInfo;
|
|
280
|
+
geometry.useBoundingInfoFromGeometry = true;
|
|
281
|
+
}
|
|
279
282
|
if (meshData.indices) {
|
|
280
283
|
geometry.setIndices(meshData.indices);
|
|
281
284
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dracoCompression.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompression.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAoC,cAAc,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAY7H,SAAS,kBAAkB,CAAC,UAAwB,EAAE,QAA6B;IAC/E,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAA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,GAAG,MAAM,IAAI,CAAC,yBAAyB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACxE,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QACpC,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACnB,UAAU,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC;QAC1C,CAAC;QACD,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;YAC1C,MAAM,SAAS,GAAG,YAAY,CAAC,YAAY,CACvC,SAAS,CAAC,IAAI,EACd,SAAS,CAAC,IAAI,EACd,YAAY,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,EACxC,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,SAAS,CAAC,UAAU,EACpB,QAAQ,CAAC,aAAa,CACzB,CAAC;YAEF,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;;AAtWD;;;;;GAKG;AACW,8BAAa,GAAmC;IAC1D,OAAO,EAAE;QACL,OAAO,EAAE,GAAG,KAAK,CAAC,cAAc,6BAA6B;QAC7D,aAAa,EAAE,GAAG,KAAK,CAAC,cAAc,0BAA0B;QAChE,WAAW,EAAE,GAAG,KAAK,CAAC,cAAc,wBAAwB;KAC/D;CACJ,CAAC;AAUF;;GAEG;AACW,kCAAiB,GAAG,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;AAW3D,yBAAQ,GAA+B,IAAI,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { AutoReleaseWorkerPool } from \"../../Misc/workerPool\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IDisposable, Scene } from \"../../scene\";\r\nimport { Geometry } from \"../geometry\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { DecoderModule } from \"draco3dgltf\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { decodeMesh, type AttributeData, type Message, workerFunction, initializeWebWorker } from \"./dracoCompressionWorker\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\ninterface MeshData {\r\n indices?: Uint16Array | Uint32Array;\r\n attributes: Array<AttributeData>;\r\n totalVertices: number;\r\n}\r\n\r\nfunction createDecoderAsync(wasmBinary?: ArrayBuffer, jsModule?: DracoDecoderModule): Promise<{ module: DecoderModule }> {\r\n return new Promise((resolve) => {\r\n (jsModule || DracoDecoderModule)({ wasmBinary }).then((module) => {\r\n resolve({ module });\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Configuration for Draco compression\r\n */\r\nexport interface IDracoCompressionConfiguration {\r\n /**\r\n * Configuration for the decoder.\r\n */\r\n decoder: {\r\n /**\r\n * The url to the WebAssembly module.\r\n */\r\n wasmUrl?: string;\r\n\r\n /**\r\n * The url to the WebAssembly binary.\r\n */\r\n wasmBinaryUrl?: string;\r\n\r\n /**\r\n * The url to the fallback JavaScript module.\r\n */\r\n fallbackUrl?: string;\r\n /**\r\n * Optional worker pool to use for async decoding instead of creating a new worker pool.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n\r\n /**\r\n * The decoder module if already available.\r\n */\r\n jsModule?: any /* DecoderModule */;\r\n };\r\n}\r\n\r\n/**\r\n * Options for Draco compression\r\n */\r\nexport interface IDracoCompressionOptions {\r\n /**\r\n * The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n numWorkers?: number;\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary.\r\n * If provided it will be used instead of loading the binary from wasmBinaryUrl.\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n /**\r\n * Optional worker pool to use for async decoding.\r\n * If provided, numWorkers will be ignored and the worker pool will be used instead.\r\n * If provided the draco script will not be loaded from the DracoConfiguration.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n}\r\n\r\n/**\r\n * Draco compression (https://google.github.io/draco/)\r\n *\r\n * This class wraps the Draco module.\r\n *\r\n * **Encoder**\r\n *\r\n * The encoder is not currently implemented.\r\n *\r\n * **Decoder**\r\n *\r\n * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.\r\n *\r\n * To update the configuration, use the following code:\r\n * ```javascript\r\n * DracoCompression.Configuration = {\r\n * decoder: {\r\n * wasmUrl: \"<url to the WebAssembly library>\",\r\n * wasmBinaryUrl: \"<url to the WebAssembly binary>\",\r\n * fallbackUrl: \"<url to the fallback JavaScript library>\",\r\n * }\r\n * };\r\n * ```\r\n *\r\n * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.\r\n * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.\r\n * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.\r\n *\r\n * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshToGeometryAsync:\r\n * ```javascript\r\n * var geometry = await DracoCompression.Default.decodeMeshToGeometryAsync(data);\r\n * ```\r\n *\r\n * @see https://playground.babylonjs.com/#DMZIBD#0\r\n */\r\nexport class DracoCompression implements IDisposable {\r\n private _workerPoolPromise?: Promise<AutoReleaseWorkerPool>;\r\n private _decoderModulePromise?: Promise<{ module: DecoderModule }>;\r\n\r\n /**\r\n * The configuration. Defaults to the following urls:\r\n * - wasmUrl: \"https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js\"\r\n * - wasmBinaryUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.wasm\"\r\n * - fallbackUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.js\"\r\n */\r\n public static Configuration: IDracoCompressionConfiguration = {\r\n decoder: {\r\n wasmUrl: `${Tools._DefaultCdnUrl}/draco_wasm_wrapper_gltf.js`,\r\n wasmBinaryUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.wasm`,\r\n fallbackUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.js`,\r\n },\r\n };\r\n\r\n /**\r\n * Returns true if the decoder configuration is available.\r\n */\r\n public static get DecoderAvailable(): boolean {\r\n const decoder = DracoCompression.Configuration.decoder;\r\n return !!((decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\") || decoder.fallbackUrl);\r\n }\r\n\r\n /**\r\n * Default number of workers to create when creating the draco compression object.\r\n */\r\n public static DefaultNumWorkers = DracoCompression.GetDefaultNumWorkers();\r\n\r\n private static GetDefaultNumWorkers(): number {\r\n if (typeof navigator !== \"object\" || !navigator.hardwareConcurrency) {\r\n return 1;\r\n }\r\n\r\n // Use 50% of the available logical processors but capped at 4.\r\n return Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);\r\n }\r\n\r\n private static _Default: Nullable<DracoCompression> = null;\r\n\r\n /**\r\n * Default instance for the draco compression object.\r\n */\r\n public static get Default(): DracoCompression {\r\n if (!DracoCompression._Default) {\r\n DracoCompression._Default = new DracoCompression();\r\n }\r\n\r\n return DracoCompression._Default;\r\n }\r\n\r\n /**\r\n * Reset the default draco compression object to null and disposing the removed default instance.\r\n * Note that if the workerPool is a member of the static Configuration object it is recommended not to run dispose,\r\n * unless the static worker pool is no longer needed.\r\n * @param skipDispose set to true to not dispose the removed default instance\r\n */\r\n public static ResetDefault(skipDispose?: boolean): void {\r\n if (DracoCompression._Default) {\r\n if (!skipDispose) {\r\n DracoCompression._Default.dispose();\r\n }\r\n DracoCompression._Default = null;\r\n }\r\n }\r\n\r\n /**\r\n * Constructor\r\n * @param numWorkers The number of workers for async operations Or an options object. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n constructor(numWorkers: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers) {\r\n const decoder = DracoCompression.Configuration.decoder;\r\n // check if the decoder binary and worker pool was injected\r\n // Note - it is expected that the developer checked if WebWorker, WebAssembly and the URL object are available\r\n if (decoder.workerPool || (typeof numWorkers === \"object\" && numWorkers.workerPool)) {\r\n // set the promise accordingly\r\n this._workerPoolPromise = Promise.resolve(decoder.workerPool || (numWorkers as IDracoCompressionOptions).workerPool!);\r\n } else {\r\n // to avoid making big changes to the decider, if wasmBinary is provided use it in the wasmBinaryPromise\r\n const wasmBinaryProvided = decoder.wasmBinary || (typeof numWorkers === \"object\" && numWorkers.wasmBinary);\r\n const numberOfWorkers = typeof numWorkers === \"number\" ? numWorkers : numWorkers.numWorkers;\r\n const useWorkers = numberOfWorkers && typeof Worker === \"function\" && typeof URL === \"function\";\r\n const urlNeeded = useWorkers || (!useWorkers && !decoder.jsModule);\r\n // code maintained here for back-compat with no changes\r\n\r\n const decoderInfo: { url: string | undefined; wasmBinaryPromise: Promise<ArrayBuffer | undefined> } =\r\n decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\"\r\n ? {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.wasmUrl, true) : \"\",\r\n wasmBinaryPromise: wasmBinaryProvided ? Promise.resolve(wasmBinaryProvided) : Tools.LoadFileAsync(Tools.GetBabylonScriptURL(decoder.wasmBinaryUrl, true)),\r\n }\r\n : {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.fallbackUrl!) : \"\",\r\n wasmBinaryPromise: Promise.resolve(undefined),\r\n };\r\n if (useWorkers) {\r\n this._workerPoolPromise = decoderInfo.wasmBinaryPromise.then((decoderWasmBinary) => {\r\n const workerContent = `${decodeMesh}(${workerFunction})()`;\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n\r\n return new AutoReleaseWorkerPool(numberOfWorkers as number, () => {\r\n const worker = new Worker(workerBlobUrl);\r\n return initializeWebWorker(worker, decoderWasmBinary, decoderInfo.url);\r\n });\r\n });\r\n } else {\r\n this._decoderModulePromise = decoderInfo.wasmBinaryPromise.then(async (decoderWasmBinary) => {\r\n if (typeof DracoDecoderModule === \"undefined\") {\r\n if (!decoder.jsModule) {\r\n if (!decoderInfo.url) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n await Tools.LoadBabylonScriptAsync(decoderInfo.url);\r\n }\r\n }\r\n return await createDecoderAsync(decoderWasmBinary as ArrayBuffer, decoder.jsModule);\r\n });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n if (this._workerPoolPromise) {\r\n this._workerPoolPromise.then((workerPool) => {\r\n workerPool.dispose();\r\n });\r\n }\r\n\r\n delete this._workerPoolPromise;\r\n delete this._decoderModulePromise;\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.\r\n * @returns a promise that resolves when ready\r\n */\r\n public async whenReadyAsync(): Promise<void> {\r\n if (this._workerPoolPromise) {\r\n await this._workerPoolPromise;\r\n return;\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n await this._decoderModulePromise;\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to mesh data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @param gltfNormalizedOverride A map of attributes from vertex buffer kinds to normalized flags to override the Draco normalization\r\n * @returns A promise that resolves with the decoded mesh data\r\n */\r\n public decodeMeshToMeshDataAsync(\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes?: { [kind: string]: number },\r\n gltfNormalizedOverride?: { [kind: string]: boolean }\r\n ): Promise<MeshData> {\r\n const dataView = data instanceof ArrayBuffer ? new Int8Array(data) : new Int8Array(data.buffer, data.byteOffset, data.byteLength);\r\n\r\n const applyGltfNormalizedOverride = (kind: string, normalized: boolean): boolean => {\r\n if (gltfNormalizedOverride && gltfNormalizedOverride[kind] !== undefined) {\r\n if (normalized !== gltfNormalizedOverride[kind]) {\r\n Logger.Warn(\r\n `Normalized flag from Draco data (${normalized}) does not match normalized flag from glTF accessor (${gltfNormalizedOverride[kind]}). Using flag from glTF accessor.`\r\n );\r\n }\r\n\r\n return gltfNormalizedOverride[kind];\r\n } else {\r\n return normalized;\r\n }\r\n };\r\n\r\n if (this._workerPoolPromise) {\r\n return this._workerPoolPromise.then((workerPool) => {\r\n return new Promise<MeshData>((resolve, reject) => {\r\n workerPool.push((worker, onComplete) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n onComplete();\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"decodeMeshDone\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve({ indices: resultIndices!, attributes: resultAttributes, totalVertices: message.totalVertices });\r\n onComplete();\r\n break;\r\n }\r\n case \"indices\": {\r\n resultIndices = message.data;\r\n break;\r\n }\r\n case \"attribute\": {\r\n resultAttributes.push({\r\n kind: message.kind,\r\n data: message.data,\r\n size: message.size,\r\n byteOffset: message.byteOffset,\r\n byteStride: message.byteStride,\r\n normalized: applyGltfNormalizedOverride(message.kind, message.normalized),\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n const dataViewCopy = dataView.slice();\r\n worker.postMessage({ id: \"decodeMesh\", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);\r\n });\r\n });\r\n });\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n return this._decoderModulePromise.then((decoder) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const numPoints = decodeMesh(\r\n decoder.module,\r\n dataView,\r\n attributes,\r\n (indices) => {\r\n resultIndices = indices;\r\n },\r\n (kind, data, size, byteOffset, byteStride, normalized) => {\r\n resultAttributes.push({\r\n kind,\r\n data,\r\n size,\r\n byteOffset,\r\n byteStride,\r\n normalized,\r\n });\r\n }\r\n );\r\n\r\n return { indices: resultIndices!, attributes: resultAttributes, totalVertices: numPoints };\r\n });\r\n }\r\n\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon geometry.\r\n * @param name The name to use when creating the geometry\r\n * @param scene The scene to use when creating the geometry\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded geometry\r\n */\r\n public async decodeMeshToGeometryAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<Geometry> {\r\n const meshData = await this.decodeMeshToMeshDataAsync(data, attributes);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\r\n }\r\n\r\n /** @internal */\r\n public async _decodeMeshToGeometryForGltfAsync(\r\n name: string,\r\n scene: Scene,\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes: { [kind: string]: number },\r\n gltfNormalizedOverride: { [kind: string]: boolean }\r\n ): Promise<Geometry> {\r\n const meshData = await this.decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon vertex data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded vertex data\r\n * @deprecated Use {@link decodeMeshToGeometryAsync} for better performance in some cases\r\n */\r\n public async decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<VertexData> {\r\n const meshData = await this.decodeMeshToMeshDataAsync(data, attributes);\r\n const vertexData = new VertexData();\r\n if (meshData.indices) {\r\n vertexData.indices = meshData.indices;\r\n }\r\n for (const attribute of meshData.attributes) {\r\n const floatData = VertexBuffer.GetFloatData(\r\n attribute.data,\r\n attribute.size,\r\n VertexBuffer.GetDataType(attribute.data),\r\n attribute.byteOffset,\r\n attribute.byteStride,\r\n attribute.normalized,\r\n meshData.totalVertices\r\n );\r\n\r\n vertexData.set(floatData, attribute.kind);\r\n }\r\n return vertexData;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"dracoCompression.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Compression/dracoCompression.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,E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;GAKG;AACW,8BAAa,GAAmC;IAC1D,OAAO,EAAE;QACL,OAAO,EAAE,GAAG,KAAK,CAAC,cAAc,6BAA6B;QAC7D,aAAa,EAAE,GAAG,KAAK,CAAC,cAAc,0BAA0B;QAChE,WAAW,EAAE,GAAG,KAAK,CAAC,cAAc,wBAAwB;KAC/D;CACJ,CAAC;AAUF;;GAEG;AACW,kCAAiB,GAAG,gBAAgB,CAAC,oBAAoB,EAAE,CAAC;AAW3D,yBAAQ,GAA+B,IAAI,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { BoundingInfo } from \"../../Culling/boundingInfo\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { AutoReleaseWorkerPool } from \"../../Misc/workerPool\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { IDisposable, Scene } from \"../../scene\";\r\nimport { Geometry } from \"../geometry\";\r\nimport { VertexBuffer } from \"../buffer\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport type { DecoderModule } from \"draco3dgltf\";\r\nimport { Logger } from \"../../Misc/logger\";\r\nimport { decodeMesh, type AttributeData, type Message, workerFunction, initializeWebWorker } from \"./dracoCompressionWorker\";\r\nimport { DracoDecoderModule } from \"draco3dgltf\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let DracoDecoderModule: DracoDecoderModule;\r\n\r\ninterface MeshData {\r\n indices?: Uint16Array | Uint32Array;\r\n attributes: Array<AttributeData>;\r\n totalVertices: number;\r\n}\r\n\r\nfunction createDecoderAsync(wasmBinary?: ArrayBuffer, jsModule?: DracoDecoderModule): Promise<{ module: DecoderModule }> {\r\n return new Promise((resolve) => {\r\n (jsModule || DracoDecoderModule)({ wasmBinary }).then((module) => {\r\n resolve({ module });\r\n });\r\n });\r\n}\r\n\r\n/**\r\n * Configuration for Draco compression\r\n */\r\nexport interface IDracoCompressionConfiguration {\r\n /**\r\n * Configuration for the decoder.\r\n */\r\n decoder: {\r\n /**\r\n * The url to the WebAssembly module.\r\n */\r\n wasmUrl?: string;\r\n\r\n /**\r\n * The url to the WebAssembly binary.\r\n */\r\n wasmBinaryUrl?: string;\r\n\r\n /**\r\n * The url to the fallback JavaScript module.\r\n */\r\n fallbackUrl?: string;\r\n /**\r\n * Optional worker pool to use for async decoding instead of creating a new worker pool.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n\r\n /**\r\n * The decoder module if already available.\r\n */\r\n jsModule?: any /* DecoderModule */;\r\n };\r\n}\r\n\r\n/**\r\n * Options for Draco compression\r\n */\r\nexport interface IDracoCompressionOptions {\r\n /**\r\n * The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n numWorkers?: number;\r\n /**\r\n * Optional ArrayBuffer of the WebAssembly binary.\r\n * If provided it will be used instead of loading the binary from wasmBinaryUrl.\r\n */\r\n wasmBinary?: ArrayBuffer;\r\n /**\r\n * Optional worker pool to use for async decoding.\r\n * If provided, numWorkers will be ignored and the worker pool will be used instead.\r\n * If provided the draco script will not be loaded from the DracoConfiguration.\r\n */\r\n workerPool?: AutoReleaseWorkerPool;\r\n}\r\n\r\n/**\r\n * Draco compression (https://google.github.io/draco/)\r\n *\r\n * This class wraps the Draco module.\r\n *\r\n * **Encoder**\r\n *\r\n * The encoder is not currently implemented.\r\n *\r\n * **Decoder**\r\n *\r\n * By default, the configuration points to a copy of the Draco decoder files for glTF from the babylon.js preview cdn https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js.\r\n *\r\n * To update the configuration, use the following code:\r\n * ```javascript\r\n * DracoCompression.Configuration = {\r\n * decoder: {\r\n * wasmUrl: \"<url to the WebAssembly library>\",\r\n * wasmBinaryUrl: \"<url to the WebAssembly binary>\",\r\n * fallbackUrl: \"<url to the fallback JavaScript library>\",\r\n * }\r\n * };\r\n * ```\r\n *\r\n * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support WebAssembly or only support the JavaScript version.\r\n * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.\r\n * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.\r\n *\r\n * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshToGeometryAsync:\r\n * ```javascript\r\n * var geometry = await DracoCompression.Default.decodeMeshToGeometryAsync(data);\r\n * ```\r\n *\r\n * @see https://playground.babylonjs.com/#DMZIBD#0\r\n */\r\nexport class DracoCompression implements IDisposable {\r\n private _workerPoolPromise?: Promise<AutoReleaseWorkerPool>;\r\n private _decoderModulePromise?: Promise<{ module: DecoderModule }>;\r\n\r\n /**\r\n * The configuration. Defaults to the following urls:\r\n * - wasmUrl: \"https://cdn.babylonjs.com/draco_wasm_wrapper_gltf.js\"\r\n * - wasmBinaryUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.wasm\"\r\n * - fallbackUrl: \"https://cdn.babylonjs.com/draco_decoder_gltf.js\"\r\n */\r\n public static Configuration: IDracoCompressionConfiguration = {\r\n decoder: {\r\n wasmUrl: `${Tools._DefaultCdnUrl}/draco_wasm_wrapper_gltf.js`,\r\n wasmBinaryUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.wasm`,\r\n fallbackUrl: `${Tools._DefaultCdnUrl}/draco_decoder_gltf.js`,\r\n },\r\n };\r\n\r\n /**\r\n * Returns true if the decoder configuration is available.\r\n */\r\n public static get DecoderAvailable(): boolean {\r\n const decoder = DracoCompression.Configuration.decoder;\r\n return !!((decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\") || decoder.fallbackUrl);\r\n }\r\n\r\n /**\r\n * Default number of workers to create when creating the draco compression object.\r\n */\r\n public static DefaultNumWorkers = DracoCompression.GetDefaultNumWorkers();\r\n\r\n private static GetDefaultNumWorkers(): number {\r\n if (typeof navigator !== \"object\" || !navigator.hardwareConcurrency) {\r\n return 1;\r\n }\r\n\r\n // Use 50% of the available logical processors but capped at 4.\r\n return Math.min(Math.floor(navigator.hardwareConcurrency * 0.5), 4);\r\n }\r\n\r\n private static _Default: Nullable<DracoCompression> = null;\r\n\r\n /**\r\n * Default instance for the draco compression object.\r\n */\r\n public static get Default(): DracoCompression {\r\n if (!DracoCompression._Default) {\r\n DracoCompression._Default = new DracoCompression();\r\n }\r\n\r\n return DracoCompression._Default;\r\n }\r\n\r\n /**\r\n * Reset the default draco compression object to null and disposing the removed default instance.\r\n * Note that if the workerPool is a member of the static Configuration object it is recommended not to run dispose,\r\n * unless the static worker pool is no longer needed.\r\n * @param skipDispose set to true to not dispose the removed default instance\r\n */\r\n public static ResetDefault(skipDispose?: boolean): void {\r\n if (DracoCompression._Default) {\r\n if (!skipDispose) {\r\n DracoCompression._Default.dispose();\r\n }\r\n DracoCompression._Default = null;\r\n }\r\n }\r\n\r\n /**\r\n * Constructor\r\n * @param numWorkers The number of workers for async operations Or an options object. Specify `0` to disable web workers and run synchronously in the current context.\r\n */\r\n constructor(numWorkers: number | IDracoCompressionOptions = DracoCompression.DefaultNumWorkers) {\r\n const decoder = DracoCompression.Configuration.decoder;\r\n // check if the decoder binary and worker pool was injected\r\n // Note - it is expected that the developer checked if WebWorker, WebAssembly and the URL object are available\r\n if (decoder.workerPool || (typeof numWorkers === \"object\" && numWorkers.workerPool)) {\r\n // set the promise accordingly\r\n this._workerPoolPromise = Promise.resolve(decoder.workerPool || (numWorkers as IDracoCompressionOptions).workerPool!);\r\n } else {\r\n // to avoid making big changes to the decider, if wasmBinary is provided use it in the wasmBinaryPromise\r\n const wasmBinaryProvided = decoder.wasmBinary || (typeof numWorkers === \"object\" && numWorkers.wasmBinary);\r\n const numberOfWorkers = typeof numWorkers === \"number\" ? numWorkers : numWorkers.numWorkers;\r\n const useWorkers = numberOfWorkers && typeof Worker === \"function\" && typeof URL === \"function\";\r\n const urlNeeded = useWorkers || (!useWorkers && !decoder.jsModule);\r\n // code maintained here for back-compat with no changes\r\n\r\n const decoderInfo: { url: string | undefined; wasmBinaryPromise: Promise<ArrayBuffer | undefined> } =\r\n decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === \"object\"\r\n ? {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.wasmUrl, true) : \"\",\r\n wasmBinaryPromise: wasmBinaryProvided ? Promise.resolve(wasmBinaryProvided) : Tools.LoadFileAsync(Tools.GetBabylonScriptURL(decoder.wasmBinaryUrl, true)),\r\n }\r\n : {\r\n url: urlNeeded ? Tools.GetBabylonScriptURL(decoder.fallbackUrl!) : \"\",\r\n wasmBinaryPromise: Promise.resolve(undefined),\r\n };\r\n if (useWorkers) {\r\n this._workerPoolPromise = decoderInfo.wasmBinaryPromise.then((decoderWasmBinary) => {\r\n const workerContent = `${decodeMesh}(${workerFunction})()`;\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n\r\n return new AutoReleaseWorkerPool(numberOfWorkers as number, () => {\r\n const worker = new Worker(workerBlobUrl);\r\n return initializeWebWorker(worker, decoderWasmBinary, decoderInfo.url);\r\n });\r\n });\r\n } else {\r\n this._decoderModulePromise = decoderInfo.wasmBinaryPromise.then(async (decoderWasmBinary) => {\r\n if (typeof DracoDecoderModule === \"undefined\") {\r\n if (!decoder.jsModule) {\r\n if (!decoderInfo.url) {\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n await Tools.LoadBabylonScriptAsync(decoderInfo.url);\r\n }\r\n }\r\n return await createDecoderAsync(decoderWasmBinary as ArrayBuffer, decoder.jsModule);\r\n });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Stop all async operations and release resources.\r\n */\r\n public dispose(): void {\r\n if (this._workerPoolPromise) {\r\n this._workerPoolPromise.then((workerPool) => {\r\n workerPool.dispose();\r\n });\r\n }\r\n\r\n delete this._workerPoolPromise;\r\n delete this._decoderModulePromise;\r\n }\r\n\r\n /**\r\n * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.\r\n * @returns a promise that resolves when ready\r\n */\r\n public async whenReadyAsync(): Promise<void> {\r\n if (this._workerPoolPromise) {\r\n await this._workerPoolPromise;\r\n return;\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n await this._decoderModulePromise;\r\n return;\r\n }\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to mesh data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @param gltfNormalizedOverride A map of attributes from vertex buffer kinds to normalized flags to override the Draco normalization\r\n * @returns A promise that resolves with the decoded mesh data\r\n */\r\n public decodeMeshToMeshDataAsync(\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes?: { [kind: string]: number },\r\n gltfNormalizedOverride?: { [kind: string]: boolean }\r\n ): Promise<MeshData> {\r\n const dataView = data instanceof ArrayBuffer ? new Int8Array(data) : new Int8Array(data.buffer, data.byteOffset, data.byteLength);\r\n\r\n const applyGltfNormalizedOverride = (kind: string, normalized: boolean): boolean => {\r\n if (gltfNormalizedOverride && gltfNormalizedOverride[kind] !== undefined) {\r\n if (normalized !== gltfNormalizedOverride[kind]) {\r\n Logger.Warn(\r\n `Normalized flag from Draco data (${normalized}) does not match normalized flag from glTF accessor (${gltfNormalizedOverride[kind]}). Using flag from glTF accessor.`\r\n );\r\n }\r\n\r\n return gltfNormalizedOverride[kind];\r\n } else {\r\n return normalized;\r\n }\r\n };\r\n\r\n if (this._workerPoolPromise) {\r\n return this._workerPoolPromise.then((workerPool) => {\r\n return new Promise<MeshData>((resolve, reject) => {\r\n workerPool.push((worker, onComplete) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n onComplete();\r\n };\r\n\r\n const onMessage = (event: MessageEvent<Message>) => {\r\n const message = event.data;\r\n switch (message.id) {\r\n case \"decodeMeshDone\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve({ indices: resultIndices!, attributes: resultAttributes, totalVertices: message.totalVertices });\r\n onComplete();\r\n break;\r\n }\r\n case \"indices\": {\r\n resultIndices = message.data;\r\n break;\r\n }\r\n case \"attribute\": {\r\n resultAttributes.push({\r\n kind: message.kind,\r\n data: message.data,\r\n size: message.size,\r\n byteOffset: message.byteOffset,\r\n byteStride: message.byteStride,\r\n normalized: applyGltfNormalizedOverride(message.kind, message.normalized),\r\n });\r\n break;\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n const dataViewCopy = dataView.slice();\r\n worker.postMessage({ id: \"decodeMesh\", dataView: dataViewCopy, attributes: attributes }, [dataViewCopy.buffer]);\r\n });\r\n });\r\n });\r\n }\r\n\r\n if (this._decoderModulePromise) {\r\n return this._decoderModulePromise.then((decoder) => {\r\n let resultIndices: Nullable<Uint16Array | Uint32Array> = null;\r\n const resultAttributes: Array<AttributeData> = [];\r\n\r\n const numPoints = decodeMesh(\r\n decoder.module,\r\n dataView,\r\n attributes,\r\n (indices) => {\r\n resultIndices = indices;\r\n },\r\n (kind, data, size, byteOffset, byteStride, normalized) => {\r\n resultAttributes.push({\r\n kind,\r\n data,\r\n size,\r\n byteOffset,\r\n byteStride,\r\n normalized,\r\n });\r\n }\r\n );\r\n\r\n return { indices: resultIndices!, attributes: resultAttributes, totalVertices: numPoints };\r\n });\r\n }\r\n\r\n throw new Error(\"Draco decoder module is not available\");\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon geometry.\r\n * @param name The name to use when creating the geometry\r\n * @param scene The scene to use when creating the geometry\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded geometry\r\n */\r\n public async decodeMeshToGeometryAsync(name: string, scene: Scene, data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<Geometry> {\r\n const meshData = await this.decodeMeshToMeshDataAsync(data, attributes);\r\n const geometry = new Geometry(name, scene);\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\r\n }\r\n\r\n /** @internal */\r\n public async _decodeMeshToGeometryForGltfAsync(\r\n name: string,\r\n scene: Scene,\r\n data: ArrayBuffer | ArrayBufferView,\r\n attributes: { [kind: string]: number },\r\n gltfNormalizedOverride: { [kind: string]: boolean },\r\n boundingInfo: Nullable<BoundingInfo>\r\n ): Promise<Geometry> {\r\n const meshData = await this.decodeMeshToMeshDataAsync(data, attributes, gltfNormalizedOverride);\r\n const geometry = new Geometry(name, scene);\r\n if (boundingInfo) {\r\n geometry._boundingInfo = boundingInfo;\r\n geometry.useBoundingInfoFromGeometry = true;\r\n }\r\n if (meshData.indices) {\r\n geometry.setIndices(meshData.indices);\r\n }\r\n for (const attribute of meshData.attributes) {\r\n geometry.setVerticesBuffer(\r\n new VertexBuffer(\r\n scene.getEngine(),\r\n attribute.data,\r\n attribute.kind,\r\n false,\r\n undefined,\r\n attribute.byteStride,\r\n undefined,\r\n attribute.byteOffset,\r\n attribute.size,\r\n undefined,\r\n attribute.normalized,\r\n true\r\n ),\r\n meshData.totalVertices\r\n );\r\n }\r\n return geometry;\r\n }\r\n\r\n /**\r\n * Decode Draco compressed mesh data to Babylon vertex data.\r\n * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data\r\n * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids\r\n * @returns A promise that resolves with the decoded vertex data\r\n * @deprecated Use {@link decodeMeshToGeometryAsync} for better performance in some cases\r\n */\r\n public async decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: { [kind: string]: number }): Promise<VertexData> {\r\n const meshData = await this.decodeMeshToMeshDataAsync(data, attributes);\r\n const vertexData = new VertexData();\r\n if (meshData.indices) {\r\n vertexData.indices = meshData.indices;\r\n }\r\n for (const attribute of meshData.attributes) {\r\n const floatData = VertexBuffer.GetFloatData(\r\n attribute.data,\r\n attribute.size,\r\n VertexBuffer.GetDataType(attribute.data),\r\n attribute.byteOffset,\r\n attribute.byteStride,\r\n attribute.normalized,\r\n meshData.totalVertices\r\n );\r\n\r\n vertexData.set(floatData, attribute.kind);\r\n }\r\n return vertexData;\r\n }\r\n}\r\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { NodeGeometryBlock } from "../../nodeGeometryBlock.js";
|
|
2
2
|
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
3
3
|
import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js";
|
|
4
|
-
import { GeometryInputBlock } from "../geometryInputBlock.js";
|
|
5
4
|
import { Matrix } from "../../../../Maths/math.vector.js";
|
|
6
5
|
/**
|
|
7
6
|
* Block used to get a rotation matrix on X Axis
|
|
@@ -13,7 +12,7 @@ export class RotationXBlock extends NodeGeometryBlock {
|
|
|
13
12
|
*/
|
|
14
13
|
constructor(name) {
|
|
15
14
|
super(name);
|
|
16
|
-
this.registerInput("angle", NodeGeometryBlockConnectionPointTypes.Float,
|
|
15
|
+
this.registerInput("angle", NodeGeometryBlockConnectionPointTypes.Float, true, 0);
|
|
17
16
|
this.registerOutput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix);
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
@@ -35,13 +34,6 @@ export class RotationXBlock extends NodeGeometryBlock {
|
|
|
35
34
|
get matrix() {
|
|
36
35
|
return this._outputs[0];
|
|
37
36
|
}
|
|
38
|
-
autoConfigure() {
|
|
39
|
-
if (!this.angle.isConnected) {
|
|
40
|
-
const angleInput = new GeometryInputBlock("Angle");
|
|
41
|
-
angleInput.value = 0;
|
|
42
|
-
angleInput.output.connectTo(this.angle);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
37
|
_buildBlock(state) {
|
|
46
38
|
super._buildBlock(state);
|
|
47
39
|
this.matrix._storedFunction = (state) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotationXBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Matrices/rotationXBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"rotationXBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Matrices/rotationXBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IACjD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAClF,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,MAAM,CAAC,CAAC;IAChF,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAEkB,WAAW,CAAC,KAA6B;QACxD,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEzB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport { Matrix } from \"../../../../Maths/math.vector\";\r\n\r\n/**\r\n * Block used to get a rotation matrix on X Axis\r\n */\r\nexport class RotationXBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new RotationXBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"angle\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\r\n this.registerOutput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"RotationXBlock\";\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the matrix output component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.matrix._storedFunction = (state) => {\r\n return Matrix.RotationX(this.angle.getConnectedValue(state));\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RotationXBlock\", RotationXBlock);\r\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { NodeGeometryBlock } from "../../nodeGeometryBlock.js";
|
|
2
2
|
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
3
3
|
import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js";
|
|
4
|
-
import { GeometryInputBlock } from "../geometryInputBlock.js";
|
|
5
4
|
import { Matrix } from "../../../../Maths/math.vector.js";
|
|
6
5
|
/**
|
|
7
6
|
* Block used to get a rotation matrix on Y Axis
|
|
@@ -13,7 +12,7 @@ export class RotationYBlock extends NodeGeometryBlock {
|
|
|
13
12
|
*/
|
|
14
13
|
constructor(name) {
|
|
15
14
|
super(name);
|
|
16
|
-
this.registerInput("angle", NodeGeometryBlockConnectionPointTypes.Float,
|
|
15
|
+
this.registerInput("angle", NodeGeometryBlockConnectionPointTypes.Float, true, 0);
|
|
17
16
|
this.registerOutput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix);
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
@@ -35,13 +34,6 @@ export class RotationYBlock extends NodeGeometryBlock {
|
|
|
35
34
|
get matrix() {
|
|
36
35
|
return this._outputs[0];
|
|
37
36
|
}
|
|
38
|
-
autoConfigure() {
|
|
39
|
-
if (!this.angle.isConnected) {
|
|
40
|
-
const angleInput = new GeometryInputBlock("Angle");
|
|
41
|
-
angleInput.value = 0;
|
|
42
|
-
angleInput.output.connectTo(this.angle);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
37
|
_buildBlock(state) {
|
|
46
38
|
super._buildBlock(state);
|
|
47
39
|
this.matrix._storedFunction = (state) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotationYBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Matrices/rotationYBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"rotationYBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Matrices/rotationYBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IACjD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAClF,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,MAAM,CAAC,CAAC;IAChF,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAEkB,WAAW,CAAC,KAA6B;QACxD,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEzB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport { Matrix } from \"../../../../Maths/math.vector\";\r\n\r\n/**\r\n * Block used to get a rotation matrix on Y Axis\r\n */\r\nexport class RotationYBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new RotationYBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"angle\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\r\n this.registerOutput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"RotationYBlock\";\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the matrix output component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.matrix._storedFunction = (state) => {\r\n return Matrix.RotationY(this.angle.getConnectedValue(state));\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RotationYBlock\", RotationYBlock);\r\n"]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { NodeGeometryBlock } from "../../nodeGeometryBlock.js";
|
|
2
2
|
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
3
3
|
import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js";
|
|
4
|
-
import { GeometryInputBlock } from "../geometryInputBlock.js";
|
|
5
4
|
import { Matrix } from "../../../../Maths/math.vector.js";
|
|
6
5
|
/**
|
|
7
6
|
* Block used to get a rotation matrix on Z Axis
|
|
@@ -13,7 +12,7 @@ export class RotationZBlock extends NodeGeometryBlock {
|
|
|
13
12
|
*/
|
|
14
13
|
constructor(name) {
|
|
15
14
|
super(name);
|
|
16
|
-
this.registerInput("angle", NodeGeometryBlockConnectionPointTypes.Float,
|
|
15
|
+
this.registerInput("angle", NodeGeometryBlockConnectionPointTypes.Float, true, 0);
|
|
17
16
|
this.registerOutput("matrix", NodeGeometryBlockConnectionPointTypes.Matrix);
|
|
18
17
|
}
|
|
19
18
|
/**
|
|
@@ -35,13 +34,6 @@ export class RotationZBlock extends NodeGeometryBlock {
|
|
|
35
34
|
get matrix() {
|
|
36
35
|
return this._outputs[0];
|
|
37
36
|
}
|
|
38
|
-
autoConfigure() {
|
|
39
|
-
if (!this.angle.isConnected) {
|
|
40
|
-
const angleInput = new GeometryInputBlock("Angle");
|
|
41
|
-
angleInput.value = 0;
|
|
42
|
-
angleInput.output.connectTo(this.angle);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
37
|
_buildBlock(state) {
|
|
46
38
|
super._buildBlock(state);
|
|
47
39
|
this.matrix._storedFunction = (state) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotationZBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Matrices/rotationZBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"rotationZBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Matrices/rotationZBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IACjD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAClF,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,MAAM,CAAC,CAAC;IAChF,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAEkB,WAAW,CAAC,KAA6B;QACxD,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAEzB,IAAI,CAAC,MAAM,CAAC,eAAe,GAAG,CAAC,KAAK,EAAE,EAAE;YACpC,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport { Matrix } from \"../../../../Maths/math.vector\";\r\n\r\n/**\r\n * Block used to get a rotation matrix on Z Axis\r\n */\r\nexport class RotationZBlock extends NodeGeometryBlock {\r\n /**\r\n * Create a new RotationZBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"angle\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\r\n this.registerOutput(\"matrix\", NodeGeometryBlockConnectionPointTypes.Matrix);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"RotationZBlock\";\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the matrix output component\r\n */\r\n public get matrix(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n super._buildBlock(state);\r\n\r\n this.matrix._storedFunction = (state) => {\r\n return Matrix.RotationZ(this.angle.getConnectedValue(state));\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RotationZBlock\", RotationZBlock);\r\n"]}
|
|
@@ -116,11 +116,13 @@ export class LatticeBlock extends NodeGeometryBlock {
|
|
|
116
116
|
const positions = this._vertexData.positions;
|
|
117
117
|
const boundingInfo = extractMinAndMax(positions, 0, positions.length / 3);
|
|
118
118
|
// Building the lattice
|
|
119
|
+
const size = boundingInfo.maximum.subtract(boundingInfo.minimum);
|
|
119
120
|
this._lattice = new Lattice({
|
|
120
121
|
resolutionX: this.resolutionX,
|
|
121
122
|
resolutionY: this.resolutionY,
|
|
122
123
|
resolutionZ: this.resolutionZ,
|
|
123
|
-
size:
|
|
124
|
+
size: size,
|
|
125
|
+
position: boundingInfo.minimum.add(size.scale(0.5)),
|
|
124
126
|
});
|
|
125
127
|
for (this._currentIndexX = 0; this._currentIndexX < this.resolutionX; this._currentIndexX++) {
|
|
126
128
|
for (this._currentIndexY = 0; this._currentIndexY < this.resolutionY; this._currentIndexY++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latticeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/latticeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAIrG,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAA0B,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,OAAO,EAAE,4BAA4B;AAC9C,OAAO,EAAE,gBAAgB,EAAE,4CAAkC;AAE7D;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,iBAAiB;IAkC/C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AAG,mBAAmB,CAAC,WAAW,CAAC;YACnD,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;YACnD,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;QACvD,CAAC;IACL,CAAC;CACJ;AAnMU;IADN,sBAAsB,CAAC,kBAAkB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;qDAC3G;AAMvB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1H;AAMhB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1H;AAMhB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1H;AAmL3B,aAAa,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport { Lattice } from \"core/Meshes/lattice\";\r\nimport { extractMinAndMax } from \"core/Maths/math.functions\";\r\n\r\n/**\r\n * Block used to apply Lattice on geometry\r\n */\r\nexport class LatticeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndexX: number;\r\n private _currentIndexY: number;\r\n private _currentIndexZ: number;\r\n private _lattice: Lattice;\r\n private _indexVector3 = new Vector3();\r\n private _currentControl = new Vector3();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Resolution on x axis\r\n */\r\n @editableInPropertyPage(\"resolutionX\", PropertyTypeForEdition.Int, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionX = 3;\r\n\r\n /**\r\n * Resolution on y axis\r\n */\r\n @editableInPropertyPage(\"resolutionY\", PropertyTypeForEdition.Int, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionY = 3;\r\n\r\n /**\r\n * Resolution on z axis\r\n */\r\n @editableInPropertyPage(\"resolutionZ\", PropertyTypeForEdition.Int, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionZ = 3;\r\n\r\n /**\r\n * Create a new LatticeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"controls\", NodeGeometryBlockConnectionPointTypes.Vector3);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndexX + this.resolutionX * (this._currentIndexY + this.resolutionY * this._currentIndexZ);\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this.getExecutionIndex();\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"LatticeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the controls input component\r\n */\r\n public get controls(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual positions\r\n * In this case it will be the current position in the lattice\r\n * @returns the current position in the lattice\r\n */\r\n public getOverridePositionsContextualValue() {\r\n return this._indexVector3;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual normals\r\n * In this case it will be the current control point being processed\r\n * @returns the current control point being processed\r\n */\r\n public getOverrideNormalsContextualValue() {\r\n return this._currentControl;\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.pushExecutionContext(this);\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n\r\n if (this._vertexData) {\r\n this._vertexData = this._vertexData.clone(); // Preserve source data\r\n }\r\n\r\n if (!this._vertexData || !this._vertexData.positions) {\r\n state.restoreExecutionContext();\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n const positions = this._vertexData.positions;\r\n const boundingInfo = extractMinAndMax(positions!, 0, positions!.length / 3);\r\n\r\n // Building the lattice\r\n this._lattice = new Lattice({\r\n resolutionX: this.resolutionX,\r\n resolutionY: this.resolutionY,\r\n resolutionZ: this.resolutionZ,\r\n size: boundingInfo.maximum.subtract(boundingInfo.minimum),\r\n });\r\n\r\n for (this._currentIndexX = 0; this._currentIndexX < this.resolutionX; this._currentIndexX++) {\r\n for (this._currentIndexY = 0; this._currentIndexY < this.resolutionY; this._currentIndexY++) {\r\n for (this._currentIndexZ = 0; this._currentIndexZ < this.resolutionZ; this._currentIndexZ++) {\r\n this._indexVector3.set(this._currentIndexX, this._currentIndexY, this._currentIndexZ);\r\n const latticeControl = this._lattice.data[this._currentIndexX][this._currentIndexY][this._currentIndexZ];\r\n this._currentControl.copyFrom(latticeControl);\r\n const tempVector3 = this.controls.getConnectedValue(state) as Vector3;\r\n\r\n if (tempVector3) {\r\n latticeControl.set(tempVector3.x, tempVector3.y, tempVector3.z);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Apply lattice\r\n this._lattice.deform(positions);\r\n\r\n // Storage\r\n state.restoreExecutionContext();\r\n return this._vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n\r\n codeString += `${this._codeVariableName}.resolutionX = ${this.resolutionX};\\n`;\r\n codeString += `${this._codeVariableName}.resolutionY = ${this.resolutionY};\\n`;\r\n codeString += `${this._codeVariableName}.resolutionZ = ${this.resolutionZ};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n serializationObject.resolutionX = this.resolutionX;\r\n serializationObject.resolutionY = this.resolutionY;\r\n serializationObject.resolutionZ = this.resolutionZ;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n this.resolutionX = serializationObject.resolutionX;\r\n this.resolutionY = serializationObject.resolutionY;\r\n this.resolutionZ = serializationObject.resolutionZ;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.LatticeBlock\", LatticeBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"latticeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Set/latticeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAIrG,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAA0B,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,OAAO,EAAE,4BAA4B;AAC9C,OAAO,EAAE,gBAAgB,EAAE,4CAAkC;AAE7D;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,iBAAiB;IAkC/C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAjCR,kBAAa,GAAG,IAAI,OAAO,EAAE,CAAC;QAC9B,oBAAe,GAAG,IAAI,OAAO,EAAE,CAAC;QAExC;;;WAGG;QAEI,oBAAe,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WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;YACnD,IAAI,CAAC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;QACvD,CAAC;IACL,CAAC;CACJ;AArMU;IADN,sBAAsB,CAAC,kBAAkB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;qDAC3G;AAMvB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1H;AAMhB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1H;AAMhB;IADN,sBAAsB,CAAC,aAAa,sCAA8B,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;iDAC1H;AAqL3B,aAAa,CAAC,sBAAsB,EAAE,YAAY,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\nimport type { INodeGeometryExecutionContext } from \"../../Interfaces/nodeGeometryExecutionContext\";\r\nimport type { VertexData } from \"../../../mesh.vertexData\";\r\nimport { Vector3 } from \"../../../../Maths/math.vector\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../../Decorators/nodeDecorator\";\r\nimport { Lattice } from \"core/Meshes/lattice\";\r\nimport { extractMinAndMax } from \"core/Maths/math.functions\";\r\n\r\n/**\r\n * Block used to apply Lattice on geometry\r\n */\r\nexport class LatticeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _vertexData: VertexData;\r\n private _currentIndexX: number;\r\n private _currentIndexY: number;\r\n private _currentIndexZ: number;\r\n private _lattice: Lattice;\r\n private _indexVector3 = new Vector3();\r\n private _currentControl = new Vector3();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Resolution on x axis\r\n */\r\n @editableInPropertyPage(\"resolutionX\", PropertyTypeForEdition.Int, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionX = 3;\r\n\r\n /**\r\n * Resolution on y axis\r\n */\r\n @editableInPropertyPage(\"resolutionY\", PropertyTypeForEdition.Int, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionY = 3;\r\n\r\n /**\r\n * Resolution on z axis\r\n */\r\n @editableInPropertyPage(\"resolutionZ\", PropertyTypeForEdition.Int, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 1, max: 10 })\r\n public resolutionZ = 3;\r\n\r\n /**\r\n * Create a new LatticeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"controls\", NodeGeometryBlockConnectionPointTypes.Vector3);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndexX + this.resolutionX * (this._currentIndexY + this.resolutionY * this._currentIndexZ);\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this.getExecutionIndex();\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"LatticeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry input component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the controls input component\r\n */\r\n public get controls(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual positions\r\n * In this case it will be the current position in the lattice\r\n * @returns the current position in the lattice\r\n */\r\n public getOverridePositionsContextualValue() {\r\n return this._indexVector3;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual normals\r\n * In this case it will be the current control point being processed\r\n * @returns the current control point being processed\r\n */\r\n public getOverrideNormalsContextualValue() {\r\n return this._currentControl;\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n state.pushExecutionContext(this);\r\n\r\n this._vertexData = this.geometry.getConnectedValue(state);\r\n\r\n if (this._vertexData) {\r\n this._vertexData = this._vertexData.clone(); // Preserve source data\r\n }\r\n\r\n if (!this._vertexData || !this._vertexData.positions) {\r\n state.restoreExecutionContext();\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n const positions = this._vertexData.positions;\r\n const boundingInfo = extractMinAndMax(positions!, 0, positions!.length / 3);\r\n\r\n // Building the lattice\r\n const size = boundingInfo.maximum.subtract(boundingInfo.minimum);\r\n this._lattice = new Lattice({\r\n resolutionX: this.resolutionX,\r\n resolutionY: this.resolutionY,\r\n resolutionZ: this.resolutionZ,\r\n size: size,\r\n position: boundingInfo.minimum.add(size.scale(0.5)),\r\n });\r\n\r\n for (this._currentIndexX = 0; this._currentIndexX < this.resolutionX; this._currentIndexX++) {\r\n for (this._currentIndexY = 0; this._currentIndexY < this.resolutionY; this._currentIndexY++) {\r\n for (this._currentIndexZ = 0; this._currentIndexZ < this.resolutionZ; this._currentIndexZ++) {\r\n this._indexVector3.set(this._currentIndexX, this._currentIndexY, this._currentIndexZ);\r\n const latticeControl = this._lattice.data[this._currentIndexX][this._currentIndexY][this._currentIndexZ];\r\n this._currentControl.copyFrom(latticeControl);\r\n const tempVector3 = this.controls.getConnectedValue(state) as Vector3;\r\n\r\n if (tempVector3) {\r\n latticeControl.set(tempVector3.x, tempVector3.y, tempVector3.z);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Apply lattice\r\n this._lattice.deform(positions);\r\n\r\n // Storage\r\n state.restoreExecutionContext();\r\n return this._vertexData;\r\n };\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n\r\n codeString += `${this._codeVariableName}.resolutionX = ${this.resolutionX};\\n`;\r\n codeString += `${this._codeVariableName}.resolutionY = ${this.resolutionY};\\n`;\r\n codeString += `${this._codeVariableName}.resolutionZ = ${this.resolutionZ};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n serializationObject.resolutionX = this.resolutionX;\r\n serializationObject.resolutionY = this.resolutionY;\r\n serializationObject.resolutionZ = this.resolutionZ;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.evaluateContext !== undefined) {\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n this.resolutionX = serializationObject.resolutionX;\r\n this.resolutionY = serializationObject.resolutionY;\r\n this.resolutionZ = serializationObject.resolutionZ;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.LatticeBlock\", LatticeBlock);\r\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NodeGeometryBlock } from "../nodeGeometryBlock";
|
|
2
2
|
import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnectionPoint";
|
|
3
|
+
import type { NodeGeometry } from "../nodeGeometry";
|
|
3
4
|
/**
|
|
4
5
|
* Conditions supported by the condition block
|
|
5
6
|
*/
|
|
@@ -61,6 +62,7 @@ export declare class ConditionBlock extends NodeGeometryBlock {
|
|
|
61
62
|
* Gets the output component
|
|
62
63
|
*/
|
|
63
64
|
get output(): NodeGeometryConnectionPoint;
|
|
65
|
+
autoConfigure(nodeGeometry: NodeGeometry): void;
|
|
64
66
|
protected _buildBlock(): void;
|
|
65
67
|
protected _dumpPropertiesCode(): string;
|
|
66
68
|
/**
|
|
@@ -5,6 +5,7 @@ import { NodeGeometryBlockConnectionPointTypes } from "../Enums/nodeGeometryConn
|
|
|
5
5
|
import { editableInPropertyPage } from "../../../Decorators/nodeDecorator.js";
|
|
6
6
|
import { WithinEpsilon } from "../../../Maths/math.scalar.functions.js";
|
|
7
7
|
import { Epsilon } from "../../../Maths/math.constants.js";
|
|
8
|
+
import { GeometryInputBlock } from "./geometryInputBlock.js";
|
|
8
9
|
/**
|
|
9
10
|
* Conditions supported by the condition block
|
|
10
11
|
*/
|
|
@@ -91,6 +92,20 @@ export class ConditionBlock extends NodeGeometryBlock {
|
|
|
91
92
|
get output() {
|
|
92
93
|
return this._outputs[0];
|
|
93
94
|
}
|
|
95
|
+
autoConfigure(nodeGeometry) {
|
|
96
|
+
if (!this.ifTrue.isConnected) {
|
|
97
|
+
const minInput = nodeGeometry.getBlockByPredicate((b) => b.isInput && b.value === 1 && b.name === "True") ||
|
|
98
|
+
new GeometryInputBlock("True");
|
|
99
|
+
minInput.value = 1;
|
|
100
|
+
minInput.output.connectTo(this.ifTrue);
|
|
101
|
+
}
|
|
102
|
+
if (!this.ifFalse.isConnected) {
|
|
103
|
+
const maxInput = nodeGeometry.getBlockByPredicate((b) => b.isInput && b.value === 0 && b.name === "False") ||
|
|
104
|
+
new GeometryInputBlock("False");
|
|
105
|
+
maxInput.value = 0;
|
|
106
|
+
maxInput.output.connectTo(this.ifFalse);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
94
109
|
_buildBlock() {
|
|
95
110
|
if (!this.left.isConnected) {
|
|
96
111
|
this.output._storedFunction = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditionBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/conditionBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAElG,OAAO,EAA0B,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD;;GAEG;AACH,MAAM,CAAN,IA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AAgB,EAAE,KAAK,EAAE,mBAAmB,CAAC,cAAc,EAAE;YACtE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;YAChD,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,mBAAmB,CAAC,EAAE,EAAE;YAC9C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;SACnD;KACJ,CAAC;4CACsC;AA+I5C,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport { WithinEpsilon } from \"../../../Maths/math.scalar.functions\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\n\r\n/**\r\n * Conditions supported by the condition block\r\n */\r\nexport enum ConditionBlockTests {\r\n /** Equal */\r\n Equal,\r\n /** NotEqual */\r\n NotEqual,\r\n /** LessThan */\r\n LessThan,\r\n /** GreaterThan */\r\n GreaterThan,\r\n /** LessOrEqual */\r\n LessOrEqual,\r\n /** GreaterOrEqual */\r\n GreaterOrEqual,\r\n /** Logical Exclusive OR */\r\n Xor,\r\n /** Logical Or */\r\n Or,\r\n /** Logical And */\r\n And,\r\n}\r\n\r\n/**\r\n * Block used to evaluate a condition and return a true or false value\r\n */\r\nexport class ConditionBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets the test used by the block\r\n */\r\n @editableInPropertyPage(\"Test\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"Equal\", value: ConditionBlockTests.Equal },\r\n { label: \"NotEqual\", value: ConditionBlockTests.NotEqual },\r\n { label: \"LessThan\", value: ConditionBlockTests.LessThan },\r\n { label: \"GreaterThan\", value: ConditionBlockTests.GreaterThan },\r\n { label: \"LessOrEqual\", value: ConditionBlockTests.LessOrEqual },\r\n { label: \"GreaterOrEqual\", value: ConditionBlockTests.GreaterOrEqual },\r\n { label: \"Xor\", value: ConditionBlockTests.Xor },\r\n { label: \"Or\", value: ConditionBlockTests.Or },\r\n { label: \"And\", value: ConditionBlockTests.And },\r\n ],\r\n })\r\n public test = ConditionBlockTests.Equal;\r\n\r\n /**\r\n * Create a new ConditionBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"left\", NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\r\n this.registerInput(\"ifTrue\", NodeGeometryBlockConnectionPointTypes.AutoDetect, true, 1);\r\n this.registerInput(\"ifFalse\", NodeGeometryBlockConnectionPointTypes.AutoDetect, true, 0);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[2];\r\n this._outputs[0]._defaultConnectionPointType = NodeGeometryBlockConnectionPointTypes.Float;\r\n this._inputs[0].acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\r\n this._inputs[1].acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\r\n this._linkConnectionTypes(2, 3);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ConditionBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left input component\r\n */\r\n public get left(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right input component\r\n */\r\n public get right(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the ifTrue input component\r\n */\r\n public get ifTrue(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the ifFalse input component\r\n */\r\n public get ifFalse(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock() {\r\n if (!this.left.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const func = (state: NodeGeometryBuildState) => {\r\n const left = this.left.getConnectedValue(state) as number;\r\n const right = this.right.getConnectedValue(state) as number;\r\n let condition = false;\r\n\r\n switch (this.test) {\r\n case ConditionBlockTests.Equal:\r\n condition = WithinEpsilon(left, right, Epsilon);\r\n break;\r\n case ConditionBlockTests.NotEqual:\r\n condition = left !== right;\r\n break;\r\n case ConditionBlockTests.LessThan:\r\n condition = left < right;\r\n break;\r\n case ConditionBlockTests.GreaterThan:\r\n condition = left > right;\r\n break;\r\n case ConditionBlockTests.LessOrEqual:\r\n condition = left <= right;\r\n break;\r\n case ConditionBlockTests.GreaterOrEqual:\r\n condition = left >= right;\r\n break;\r\n case ConditionBlockTests.Xor:\r\n condition = (!!left && !right) || (!left && !!right);\r\n break;\r\n case ConditionBlockTests.Or:\r\n condition = !!left || !!right;\r\n break;\r\n case ConditionBlockTests.And:\r\n condition = !!left && !!right;\r\n break;\r\n }\r\n return condition;\r\n };\r\n\r\n this.output._storedFunction = (state) => {\r\n if (func(state)) {\r\n return this.ifTrue.getConnectedValue(state);\r\n }\r\n\r\n return this.ifFalse.getConnectedValue(state);\r\n };\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.test = BABYLON.ConditionBlockTests.${ConditionBlockTests[this.test]};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.test = this.test;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.test = serializationObject.test;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ConditionBlock\", ConditionBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"conditionBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/conditionBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAElG,OAAO,EAA0B,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;GAEG;AACH,MAAM,CAAN,IAAY,mBAmBX;AAnBD,WAAY,mBAAmB;IAC3B,YAAY;IACZ,+DAAK,CAAA;IACL,eAAe;IACf,qEAAQ,CAAA;IACR,eAAe;IACf,qEAAQ,CAAA;IACR,kBAAkB;IAClB,2EAAW,CAAA;IACX,kBAAkB;IAClB,2EAAW,CAAA;IACX,qBAAqB;IACrB,iFAAc,CAAA;IACd,2BAA2B;IAC3B,2DAAG,CAAA;IACH,iBAAiB;IACjB,yDAAE,CAAA;IACF,kBAAkB;IAClB,2DAAG,CAAA;AACP,CAAC,EAnBW,mBAAmB,KAAnB,mBAAmB,QAmB9B;AAED;;GAEG;AACH,MAAM,OAAO,cAAe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E,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,CAAC,KAAK,EAAE;YACpD,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;YAC1D,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,mBAAmB,CAAC,QAAQ,EAAE;YAC1D,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,mBAAmB,CAAC,WAAW,EAAE;YAChE,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,mBAAmB,CAAC,WAAW,EAAE;YAChE,EAAE,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,mBAAmB,CAAC,cAAc,EAAE;YACtE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;YAChD,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,mBAAmB,CAAC,EAAE,EAAE;YAC9C,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,CAAC,GAAG,EAAE;SACnD;KACJ,CAAC;4CACsC;AAiK5C,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport { WithinEpsilon } from \"../../../Maths/math.scalar.functions\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\nimport { GeometryInputBlock } from \"./geometryInputBlock\";\r\nimport type { NodeGeometry } from \"../nodeGeometry\";\r\n\r\n/**\r\n * Conditions supported by the condition block\r\n */\r\nexport enum ConditionBlockTests {\r\n /** Equal */\r\n Equal,\r\n /** NotEqual */\r\n NotEqual,\r\n /** LessThan */\r\n LessThan,\r\n /** GreaterThan */\r\n GreaterThan,\r\n /** LessOrEqual */\r\n LessOrEqual,\r\n /** GreaterOrEqual */\r\n GreaterOrEqual,\r\n /** Logical Exclusive OR */\r\n Xor,\r\n /** Logical Or */\r\n Or,\r\n /** Logical And */\r\n And,\r\n}\r\n\r\n/**\r\n * Block used to evaluate a condition and return a true or false value\r\n */\r\nexport class ConditionBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets the test used by the block\r\n */\r\n @editableInPropertyPage(\"Test\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"Equal\", value: ConditionBlockTests.Equal },\r\n { label: \"NotEqual\", value: ConditionBlockTests.NotEqual },\r\n { label: \"LessThan\", value: ConditionBlockTests.LessThan },\r\n { label: \"GreaterThan\", value: ConditionBlockTests.GreaterThan },\r\n { label: \"LessOrEqual\", value: ConditionBlockTests.LessOrEqual },\r\n { label: \"GreaterOrEqual\", value: ConditionBlockTests.GreaterOrEqual },\r\n { label: \"Xor\", value: ConditionBlockTests.Xor },\r\n { label: \"Or\", value: ConditionBlockTests.Or },\r\n { label: \"And\", value: ConditionBlockTests.And },\r\n ],\r\n })\r\n public test = ConditionBlockTests.Equal;\r\n\r\n /**\r\n * Create a new ConditionBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"left\", NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerInput(\"right\", NodeGeometryBlockConnectionPointTypes.Float, true, 0);\r\n this.registerInput(\"ifTrue\", NodeGeometryBlockConnectionPointTypes.AutoDetect, true, 1);\r\n this.registerInput(\"ifFalse\", NodeGeometryBlockConnectionPointTypes.AutoDetect, true, 0);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[2];\r\n this._outputs[0]._defaultConnectionPointType = NodeGeometryBlockConnectionPointTypes.Float;\r\n this._inputs[0].acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\r\n this._inputs[1].acceptedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Int);\r\n this._linkConnectionTypes(2, 3);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ConditionBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left input component\r\n */\r\n public get left(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right input component\r\n */\r\n public get right(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the ifTrue input component\r\n */\r\n public get ifTrue(): NodeGeometryConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the ifFalse input component\r\n */\r\n public get ifFalse(): NodeGeometryConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override autoConfigure(nodeGeometry: NodeGeometry) {\r\n if (!this.ifTrue.isConnected) {\r\n const minInput =\r\n (nodeGeometry.getBlockByPredicate((b) => b.isInput && (b as GeometryInputBlock).value === 1 && b.name === \"True\") as GeometryInputBlock) ||\r\n new GeometryInputBlock(\"True\");\r\n minInput.value = 1;\r\n minInput.output.connectTo(this.ifTrue);\r\n }\r\n\r\n if (!this.ifFalse.isConnected) {\r\n const maxInput =\r\n (nodeGeometry.getBlockByPredicate((b) => b.isInput && (b as GeometryInputBlock).value === 0 && b.name === \"False\") as GeometryInputBlock) ||\r\n new GeometryInputBlock(\"False\");\r\n maxInput.value = 0;\r\n maxInput.output.connectTo(this.ifFalse);\r\n }\r\n }\r\n\r\n protected override _buildBlock() {\r\n if (!this.left.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const func = (state: NodeGeometryBuildState) => {\r\n const left = this.left.getConnectedValue(state) as number;\r\n const right = this.right.getConnectedValue(state) as number;\r\n let condition = false;\r\n\r\n switch (this.test) {\r\n case ConditionBlockTests.Equal:\r\n condition = WithinEpsilon(left, right, Epsilon);\r\n break;\r\n case ConditionBlockTests.NotEqual:\r\n condition = left !== right;\r\n break;\r\n case ConditionBlockTests.LessThan:\r\n condition = left < right;\r\n break;\r\n case ConditionBlockTests.GreaterThan:\r\n condition = left > right;\r\n break;\r\n case ConditionBlockTests.LessOrEqual:\r\n condition = left <= right;\r\n break;\r\n case ConditionBlockTests.GreaterOrEqual:\r\n condition = left >= right;\r\n break;\r\n case ConditionBlockTests.Xor:\r\n condition = (!!left && !right) || (!left && !!right);\r\n break;\r\n case ConditionBlockTests.Or:\r\n condition = !!left || !!right;\r\n break;\r\n case ConditionBlockTests.And:\r\n condition = !!left && !!right;\r\n break;\r\n }\r\n return condition;\r\n };\r\n\r\n this.output._storedFunction = (state) => {\r\n if (func(state)) {\r\n return this.ifTrue.getConnectedValue(state);\r\n }\r\n\r\n return this.ifFalse.getConnectedValue(state);\r\n };\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.test = BABYLON.ConditionBlockTests.${ConditionBlockTests[this.test]};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.test = this.test;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.test = serializationObject.test;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ConditionBlock\", ConditionBlock);\r\n"]}
|
|
@@ -5,9 +5,11 @@ import type { NodeGeometryConnectionPoint } from "../nodeGeometryBlockConnection
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class GeometryClampBlock extends NodeGeometryBlock {
|
|
7
7
|
/** Gets or sets the minimum range */
|
|
8
|
-
minimum: number;
|
|
8
|
+
get minimum(): number;
|
|
9
|
+
set minimum(value: number);
|
|
9
10
|
/** Gets or sets the maximum range */
|
|
10
|
-
maximum: number;
|
|
11
|
+
get maximum(): number;
|
|
12
|
+
set maximum(value: number);
|
|
11
13
|
/**
|
|
12
14
|
* Creates a new GeometryClampBlock
|
|
13
15
|
* @param name defines the block name
|
|
@@ -35,7 +37,5 @@ export declare class GeometryClampBlock extends NodeGeometryBlock {
|
|
|
35
37
|
*/
|
|
36
38
|
get output(): NodeGeometryConnectionPoint;
|
|
37
39
|
protected _buildBlock(): this | undefined;
|
|
38
|
-
protected _dumpPropertiesCode(): string;
|
|
39
|
-
serialize(): any;
|
|
40
40
|
_deserialize(serializationObject: any): void;
|
|
41
41
|
}
|