@onerjs/core 8.54.2 → 8.54.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animatable.core.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSoundSource.d.ts +26 -0
- package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.js +2 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioSoundSource.d.ts +16 -0
- package/AudioV2/webAudio/webAudioSoundSource.js +43 -1
- package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
- package/Bones/skeleton.functions.js +1 -1
- package/Bones/skeleton.functions.js.map +1 -1
- package/Cameras/inputMapper.js.map +1 -1
- package/Debug/physicsViewer.pure.js +1 -1
- package/Debug/physicsViewer.pure.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js +4 -0
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.alphaToCoverage.d.ts +6 -0
- package/Engines/Extensions/engine.alphaToCoverage.js +9 -0
- package/Engines/Extensions/engine.alphaToCoverage.js.map +1 -0
- package/Engines/Extensions/engine.alphaToCoverage.pure.d.ts +6 -0
- package/Engines/Extensions/engine.alphaToCoverage.pure.js +54 -0
- package/Engines/Extensions/engine.alphaToCoverage.pure.js.map +1 -0
- package/Engines/Extensions/engine.alphaToCoverage.types.d.ts +21 -0
- package/Engines/Extensions/engine.alphaToCoverage.types.js +2 -0
- package/Engines/Extensions/engine.alphaToCoverage.types.js.map +1 -0
- package/Engines/Extensions/index.d.ts +1 -0
- package/Engines/Extensions/index.js +1 -0
- package/Engines/Extensions/index.js.map +1 -1
- package/Engines/Extensions/pure.d.ts +1 -0
- package/Engines/Extensions/pure.js +1 -0
- package/Engines/Extensions/pure.js.map +1 -1
- package/Engines/Native/nativeHelpers.js +6 -4
- package/Engines/Native/nativeHelpers.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -0
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.d.ts +6 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.js +9 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.js.map +1 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.pure.d.ts +6 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.pure.js +34 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.pure.js.map +1 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.types.d.ts +16 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.types.js +2 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.types.js.map +1 -0
- package/Engines/WebGPU/Extensions/index.d.ts +1 -0
- package/Engines/WebGPU/Extensions/index.js +1 -0
- package/Engines/WebGPU/Extensions/index.js.map +1 -1
- package/Engines/WebGPU/Extensions/pure.d.ts +1 -0
- package/Engines/WebGPU/Extensions/pure.js +1 -0
- package/Engines/WebGPU/Extensions/pure.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +0 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +0 -15
- package/Engines/abstractEngine.pure.js +2 -23
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/constants.d.ts +4 -0
- package/Engines/constants.js +4 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +2 -2
- package/Engines/engine.js +1 -0
- package/Engines/engine.js.map +1 -1
- package/Engines/engine.pure.js +1 -1
- package/Engines/engine.pure.js.map +1 -1
- package/Engines/thinEngine.pure.d.ts +0 -11
- package/Engines/thinEngine.pure.js +0 -19
- package/Engines/thinEngine.pure.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +2 -0
- package/Engines/webgpuEngine.js +2 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +0 -5
- package/Engines/webgpuEngine.pure.js +1 -10
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
- package/Loading/loadingScreen.pure.js +2 -0
- package/Loading/loadingScreen.pure.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +3 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
- package/Materials/Textures/ktx2decoderTypes.d.ts +14 -3
- package/Materials/Textures/ktx2decoderTypes.js +2 -0
- package/Materials/Textures/ktx2decoderTypes.js.map +1 -1
- package/Materials/Textures/rawTexture2DArray.functions.d.ts +29 -0
- package/Materials/Textures/rawTexture2DArray.functions.js +71 -0
- package/Materials/Textures/rawTexture2DArray.functions.js.map +1 -1
- package/Materials/material.pure.d.ts +1 -0
- package/Materials/material.pure.js +1 -0
- package/Materials/material.pure.js.map +1 -1
- package/Meshes/Builders/pure.d.ts +2 -2
- package/Meshes/Builders/pure.js +2 -2
- package/Meshes/Builders/pure.js.map +1 -1
- package/Meshes/Builders/textBuilder.js.map +1 -1
- package/Meshes/Builders/tiledBoxBuilder.d.ts +1 -83
- package/Meshes/Builders/tiledBoxBuilder.js +3 -215
- package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
- package/Meshes/Builders/tiledBoxBuilder.pure.d.ts +89 -0
- package/Meshes/Builders/tiledBoxBuilder.pure.js +229 -0
- package/Meshes/Builders/tiledBoxBuilder.pure.js.map +1 -0
- package/Meshes/Builders/tiledPlaneBuilder.d.ts +1 -79
- package/Meshes/Builders/tiledPlaneBuilder.js +3 -429
- package/Meshes/Builders/tiledPlaneBuilder.js.map +1 -1
- package/Meshes/Builders/tiledPlaneBuilder.pure.d.ts +85 -0
- package/Meshes/Builders/tiledPlaneBuilder.pure.js +442 -0
- package/Meshes/Builders/tiledPlaneBuilder.pure.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +50 -11
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +17 -4
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -1
- package/Meshes/Node/Blocks/bevelBlock.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +5 -3
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/meshBuilder.d.ts +21 -57
- package/Meshes/meshBuilder.js +21 -58
- package/Meshes/meshBuilder.js.map +1 -1
- package/Meshes/meshBuilder.pure.d.ts +58 -0
- package/Meshes/meshBuilder.pure.js +60 -0
- package/Meshes/meshBuilder.pure.js.map +1 -0
- package/Meshes/pure.d.ts +1 -1
- package/Meshes/pure.js +1 -1
- package/Meshes/pure.js.map +1 -1
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/khronosTextureContainer2.d.ts +10 -0
- package/Misc/khronosTextureContainer2.js +23 -12
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/perfCounter.d.ts +2 -0
- package/Misc/perfCounter.js +17 -2
- package/Misc/perfCounter.js.map +1 -1
- package/Misc/rgbdTextureTools.js +1 -1
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Navigation/Plugins/recastJSPlugin.js +1 -1
- package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.d.ts +15 -0
- package/Physics/v2/Plugins/havokPlugin.js +16 -6
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/characterController.js +2 -2
- package/Physics/v2/characterController.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js.map +1 -1
- package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +3 -0
- package/PostProcesses/volumetricLightScatteringPostProcess.js +3 -0
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.d.ts +1 -0
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +25 -6
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.js +6 -6
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/clusteredLightingCompute.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingCompute.js +29 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingCompute.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/depthPrePass.js +2 -0
- package/ShadersWGSL/ShadersInclude/depthPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +2 -3
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +2 -17
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js +7 -8
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.d.ts +6 -0
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js +123 -0
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.d.ts +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +2 -111
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/background.fragment.js +2 -1
- package/ShadersWGSL/background.fragment.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +5 -1
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/openpbr.fragment.js +5 -1
- package/ShadersWGSL/openpbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +5 -1
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/volumetricLightScattering.fragment.d.ts +5 -0
- package/ShadersWGSL/volumetricLightScattering.fragment.js +20 -0
- package/ShadersWGSL/volumetricLightScattering.fragment.js.map +1 -0
- package/ShadersWGSL/volumetricLightScatteringPass.fragment.d.ts +5 -0
- package/ShadersWGSL/volumetricLightScatteringPass.fragment.js +24 -0
- package/ShadersWGSL/volumetricLightScatteringPass.fragment.js.map +1 -0
- package/ShadersWGSL/volumetricLightScatteringPass.vertex.d.ts +5 -0
- package/ShadersWGSL/volumetricLightScatteringPass.vertex.js +67 -0
- package/ShadersWGSL/volumetricLightScatteringPass.vertex.js.map +1 -0
- package/SmartAssets/smartAssetManager.pure.js +9 -1
- package/SmartAssets/smartAssetManager.pure.js.map +1 -1
- package/States/alphaCullingState.d.ts +0 -9
- package/States/alphaCullingState.js +4 -31
- package/States/alphaCullingState.js.map +1 -1
- package/XR/features/WebXRLayers.pure.js +4 -4
- package/XR/features/WebXRLayers.pure.js.map +1 -1
- package/node.d.ts +18 -1
- package/node.js +52 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +7 -0
- package/scene.pure.js +8 -0
- package/scene.pure.js.map +1 -1
- package/types.js.map +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Pure barrel — re-exports only side-effect-free modules */
|
|
2
2
|
export * from "./boxBuilder.pure.js";
|
|
3
|
-
export * from "./tiledBoxBuilder.js";
|
|
3
|
+
export * from "./tiledBoxBuilder.pure.js";
|
|
4
4
|
export * from "./discBuilder.pure.js";
|
|
5
5
|
export * from "./ribbonBuilder.pure.js";
|
|
6
6
|
export * from "./sphereBuilder.pure.js";
|
|
@@ -13,7 +13,7 @@ export * from "./polygonBuilder.pure.js";
|
|
|
13
13
|
export * from "./shapeBuilder.pure.js";
|
|
14
14
|
export * from "./latheBuilder.pure.js";
|
|
15
15
|
export * from "./planeBuilder.pure.js";
|
|
16
|
-
export * from "./tiledPlaneBuilder.js";
|
|
16
|
+
export * from "./tiledPlaneBuilder.pure.js";
|
|
17
17
|
export * from "./groundBuilder.pure.js";
|
|
18
18
|
export * from "./tubeBuilder.pure.js";
|
|
19
19
|
export * from "./polyhedronBuilder.pure.js";
|
package/Meshes/Builders/pure.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Pure barrel — re-exports only side-effect-free modules */
|
|
2
2
|
export * from "./boxBuilder.pure.js";
|
|
3
|
-
export * from "./tiledBoxBuilder.js";
|
|
3
|
+
export * from "./tiledBoxBuilder.pure.js";
|
|
4
4
|
export * from "./discBuilder.pure.js";
|
|
5
5
|
export * from "./ribbonBuilder.pure.js";
|
|
6
6
|
export * from "./sphereBuilder.pure.js";
|
|
@@ -13,7 +13,7 @@ export * from "./polygonBuilder.pure.js";
|
|
|
13
13
|
export * from "./shapeBuilder.pure.js";
|
|
14
14
|
export * from "./latheBuilder.pure.js";
|
|
15
15
|
export * from "./planeBuilder.pure.js";
|
|
16
|
-
export * from "./tiledPlaneBuilder.js";
|
|
16
|
+
export * from "./tiledPlaneBuilder.pure.js";
|
|
17
17
|
export * from "./groundBuilder.pure.js";
|
|
18
18
|
export * from "./tubeBuilder.pure.js";
|
|
19
19
|
export * from "./polyhedronBuilder.pure.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,mBAAmB,CAAC;AAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\nexport * from \"./boxBuilder.pure\";\nexport * from \"./tiledBoxBuilder.pure\";\nexport * from \"./discBuilder.pure\";\nexport * from \"./ribbonBuilder.pure\";\nexport * from \"./sphereBuilder.pure\";\nexport * from \"./hemisphereBuilder.pure\";\nexport * from \"./cylinderBuilder.pure\";\nexport * from \"./torusBuilder.pure\";\nexport * from \"./torusKnotBuilder.pure\";\nexport * from \"./linesBuilder.pure\";\nexport * from \"./polygonBuilder.pure\";\nexport * from \"./shapeBuilder.pure\";\nexport * from \"./latheBuilder.pure\";\nexport * from \"./planeBuilder.pure\";\nexport * from \"./tiledPlaneBuilder.pure\";\nexport * from \"./groundBuilder.pure\";\nexport * from \"./tubeBuilder.pure\";\nexport * from \"./polyhedronBuilder.pure\";\nexport * from \"./geodesicBuilder\";\nexport * from \"./goldbergBuilder\";\nexport * from \"./decalBuilder.pure\";\nexport * from \"./icoSphereBuilder.pure\";\nexport * from \"./capsuleBuilder.pure\";\nexport * from \"./textBuilder\";\nexport * from \"./greasedLineBuilder\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/textBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAgB,MAAM,8BAA8B,CAAC;AAGrE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAyCvD,kBAAkB;AAClB,MAAM,SAAS;IAOX;;OAEG;IACH,YAAY,UAAkB;QATtB,WAAM,GAAY,EAAE,CAAC;QACrB,eAAU,GAAY,EAAE,CAAC;QACzB,WAAM,GAAY,EAAE,CAAC;QAQzB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,CAAS,EAAE,CAAS;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,CAAS,EAAE,CAAS;QACvB,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,GAAW,EAAE,GAAW,EAAE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AG,CAAC,CAAC,CAAC,QAAQ;QAChF,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,0BAA0B;QAClG,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,6BAA6B;QACzH,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,gBAAgB;QAChB,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAChD,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QAChC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;QAEvB,OAAO,CAAC,gCAAgC,EAAE,CAAC;QAE3C,mBAAmB;QACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import { type Color4 } from \"../../Maths/math.color\";\r\nimport { Path2 } from \"../../Maths/math.path\";\r\nimport { Vector3, type Vector4 } from \"../../Maths/math.vector.pure\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { Mesh } from \"../mesh.pure\";\r\nimport { TransformNode } from \"../transformNode.pure\";\r\nimport { ExtrudePolygon } from \"./polygonBuilder.pure\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let earcut: any;\r\n\r\n/**\r\n * Parser inspired by https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/FontLoader.js\r\n */\r\n\r\n// Interfaces\r\n\r\n/**\r\n * Represents glyph data generated by http://gero3.github.io/facetype.js/\r\n */\r\nexport interface IGlyphData {\r\n /** Commands used to draw (line, move, curve, etc..) */\r\n o: string;\r\n\r\n /** Width */\r\n ha: number;\r\n}\r\n\r\n/**\r\n * Represents font data generated by http://gero3.github.io/facetype.js/\r\n */\r\nexport interface IFontData {\r\n /**\r\n * Font resolution\r\n */\r\n resolution: number;\r\n /** Underline tickness */\r\n underlineThickness: number;\r\n /** Bounding box */\r\n boundingBox: {\r\n yMax: number;\r\n yMin: number;\r\n };\r\n /** List of supported glyphs */\r\n glyphs: { [key: string]: IGlyphData };\r\n}\r\n\r\n// Shape functions\r\nclass ShapePath {\r\n private _paths: Path2[] = [];\r\n private _tempPaths: Path2[] = [];\r\n private _holes: Path2[] = [];\r\n private _currentPath: Path2;\r\n private _resolution: number;\r\n\r\n /** Create the ShapePath used to support glyphs\r\n * @param resolution defines the resolution used to determine the number of points per curve (default is 4)\r\n */\r\n constructor(resolution: number) {\r\n this._resolution = resolution;\r\n }\r\n\r\n /** Move the virtual cursor to a coordinate\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n */\r\n moveTo(x: number, y: number) {\r\n this._currentPath = new Path2(x, y);\r\n this._tempPaths.push(this._currentPath);\r\n }\r\n\r\n /** Draw a line from the virtual cursor to a given coordinate\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n */\r\n lineTo(x: number, y: number) {\r\n this._currentPath.addLineTo(x, y);\r\n }\r\n\r\n /** Create a quadratic curve from the virtual cursor to a given coordinate\r\n * @param cpx defines the x coordinate of the control point\r\n * @param cpy defines the y coordinate of the control point\r\n * @param x defines the x coordinate of the end point\r\n * @param y defines the y coordinate of the end point\r\n */\r\n quadraticCurveTo(cpx: number, cpy: number, x: number, y: number) {\r\n this._currentPath.addQuadraticCurveTo(cpx, cpy, x, y, this._resolution);\r\n }\r\n\r\n /**\r\n * Create a bezier curve from the virtual cursor to a given coordinate\r\n * @param cpx1 defines the x coordinate of the first control point\r\n * @param cpy1 defines the y coordinate of the first control point\r\n * @param cpx2 defines the x coordinate of the second control point\r\n * @param cpy2 defines the y coordinate of the second control point\r\n * @param x defines the x coordinate of the end point\r\n * @param y defines the y coordinate of the end point\r\n */\r\n bezierCurveTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number) {\r\n this._currentPath.addBezierCurveTo(cpx1, cpy1, cpx2, cpy2, x, y, this._resolution);\r\n }\r\n\r\n /** Extract holes based on CW / CCW */\r\n extractHoles() {\r\n for (const path of this._tempPaths) {\r\n if (path.area() > 0) {\r\n this._holes.push(path);\r\n } else {\r\n this._paths.push(path);\r\n }\r\n }\r\n\r\n if (!this._paths.length && this._holes.length) {\r\n const temp = this._holes;\r\n this._holes = this._paths;\r\n this._paths = temp;\r\n }\r\n\r\n this._tempPaths.length = 0;\r\n }\r\n\r\n /** Gets the list of paths */\r\n get paths() {\r\n return this._paths;\r\n }\r\n\r\n /** Gets the list of holes */\r\n get holes() {\r\n return this._holes;\r\n }\r\n}\r\n\r\n// Utility functions\r\nfunction CreateShapePath(\r\n char: string,\r\n scale: number,\r\n offsetX: number,\r\n offsetY: number,\r\n resolution: number,\r\n fontData: IFontData\r\n): Nullable<{\r\n offsetX: number;\r\n shapePath: ShapePath;\r\n}> {\r\n const glyph = fontData.glyphs[char] || fontData.glyphs[\"?\"];\r\n\r\n if (!glyph) {\r\n // return if there is no glyph data\r\n return null;\r\n }\r\n\r\n const shapePath = new ShapePath(resolution);\r\n\r\n if (glyph.o) {\r\n const outline = glyph.o.split(\" \");\r\n\r\n for (let i = 0, l = outline.length; i < l; ) {\r\n const action = outline[i++];\r\n\r\n switch (action) {\r\n case \"m\": {\r\n // moveTo\r\n const x = parseInt(outline[i++]) * scale + offsetX;\r\n const y = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.moveTo(x, y);\r\n break;\r\n }\r\n case \"l\": {\r\n // lineTo\r\n const x = parseInt(outline[i++]) * scale + offsetX;\r\n const y = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.lineTo(x, y);\r\n break;\r\n }\r\n case \"q\": {\r\n // quadraticCurveTo\r\n const cpx = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy = parseInt(outline[i++]) * scale + offsetY;\r\n const cpx1 = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy1 = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.quadraticCurveTo(cpx1, cpy1, cpx, cpy);\r\n break;\r\n }\r\n case \"b\": {\r\n // bezierCurveTo\r\n const cpx = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy = parseInt(outline[i++]) * scale + offsetY;\r\n const cpx1 = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy1 = parseInt(outline[i++]) * scale + offsetY;\r\n const cpx2 = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy2 = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, cpx, cpy);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Extract holes (based on clockwise data)\r\n shapePath.extractHoles();\r\n\r\n return { offsetX: glyph.ha * scale, shapePath: shapePath };\r\n}\r\n\r\n/**\r\n * Creates shape paths from a text and font\r\n * @param text the text\r\n * @param size size of the font\r\n * @param resolution resolution of the font\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @returns array of ShapePath objects\r\n */\r\nexport function CreateTextShapePaths(text: string, size: number, resolution: number, fontData: IFontData) {\r\n const chars = Array.from(text);\r\n const scale = size / fontData.resolution;\r\n const lineHeight = (fontData.boundingBox.yMax - fontData.boundingBox.yMin + fontData.underlineThickness) * scale;\r\n\r\n const shapePaths: ShapePath[] = [];\r\n\r\n let offsetX = 0,\r\n offsetY = 0;\r\n\r\n for (let i = 0; i < chars.length; i++) {\r\n const char = chars[i];\r\n\r\n if (char === \"\\n\") {\r\n offsetX = 0;\r\n offsetY -= lineHeight;\r\n } else {\r\n const ret = CreateShapePath(char, scale, offsetX, offsetY, resolution, fontData);\r\n\r\n if (ret) {\r\n offsetX += ret.offsetX;\r\n shapePaths.push(ret.shapePath);\r\n }\r\n }\r\n }\r\n\r\n return shapePaths;\r\n}\r\n\r\n/**\r\n * Create a text mesh\r\n * @param name defines the name of the mesh\r\n * @param text defines the text to use to build the mesh\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @param options defines options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @param earcutInjection can be used to inject your own earcut reference\r\n * @returns a new Mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/text\r\n */\r\nexport function CreateText(\r\n name: string,\r\n text: string,\r\n fontData: IFontData,\r\n options: {\r\n size?: number;\r\n resolution?: number;\r\n depth?: number;\r\n sideOrientation?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n perLetterFaceUV?: (letterIndex: number) => Vector4[];\r\n perLetterFaceColors?: (letterIndex: number) => Color4[];\r\n } = {\r\n size: 50,\r\n resolution: 8,\r\n depth: 1.0,\r\n },\r\n scene: Nullable<Scene> = null,\r\n earcutInjection = earcut\r\n): Nullable<Mesh> {\r\n // First we need to generate the paths\r\n const shapePaths = CreateTextShapePaths(text, options.size || 50, options.resolution || 8, fontData);\r\n\r\n // And extrude them\r\n const meshes: Mesh[] = [];\r\n let letterIndex = 0;\r\n for (const shapePath of shapePaths) {\r\n if (!shapePath.paths.length) {\r\n continue;\r\n }\r\n\r\n const holes = shapePath.holes.slice(); // Copy it as we will update the copy\r\n for (const path of shapePath.paths) {\r\n const holeVectors: Vector3[][] = [];\r\n const shapeVectors: Vector3[] = [];\r\n const points = path.getPoints();\r\n for (const point of points) {\r\n shapeVectors.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane\r\n }\r\n\r\n // Holes\r\n const localHolesCopy = holes.slice();\r\n for (const hole of localHolesCopy) {\r\n const points = hole.getPoints();\r\n\r\n let found = false;\r\n for (const point of points) {\r\n if (path.isPointInside(point)) {\r\n found = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!found) {\r\n continue;\r\n }\r\n\r\n const holePoints: Vector3[] = [];\r\n for (const point of points) {\r\n holePoints.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane\r\n }\r\n holeVectors.push(holePoints);\r\n\r\n // Remove the hole as it was already used\r\n holes.splice(holes.indexOf(hole), 1);\r\n }\r\n\r\n // There is at least a hole but it was unaffected\r\n if (!holeVectors.length && holes.length) {\r\n for (const hole of holes) {\r\n const points = hole.getPoints();\r\n const holePoints: Vector3[] = [];\r\n for (const point of points) {\r\n holePoints.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane\r\n }\r\n holeVectors.push(holePoints);\r\n }\r\n }\r\n\r\n // Extrusion!\r\n const mesh = ExtrudePolygon(\r\n name,\r\n {\r\n shape: shapeVectors,\r\n holes: holeVectors.length ? holeVectors : undefined,\r\n depth: options.depth || 1.0,\r\n faceUV: options.faceUV || options.perLetterFaceUV?.(letterIndex),\r\n faceColors: options.faceColors || options.perLetterFaceColors?.(letterIndex),\r\n sideOrientation: Mesh._GetDefaultSideOrientation(options.sideOrientation || Mesh.DOUBLESIDE),\r\n },\r\n scene,\r\n earcutInjection\r\n );\r\n meshes.push(mesh);\r\n letterIndex++;\r\n }\r\n }\r\n\r\n // Then we can merge everyone into one single mesh\r\n const newMesh = Mesh.MergeMeshes(meshes, true, true);\r\n\r\n if (newMesh) {\r\n // Move pivot to desired center / bottom / center position\r\n const bbox = newMesh.getBoundingInfo().boundingBox;\r\n newMesh.position.x += -(bbox.minimumWorld.x + bbox.maximumWorld.x) / 2; // Mid X\r\n newMesh.position.y += -(bbox.minimumWorld.y + bbox.maximumWorld.y) / 2; // Mid Z as it will rotate\r\n newMesh.position.z += -(bbox.minimumWorld.z + bbox.maximumWorld.z) / 2 + bbox.extendSize.z; // Bottom Y as it will rotate\r\n newMesh.name = name;\r\n\r\n // Rotate 90° Up\r\n const pivot = new TransformNode(\"pivot\", scene);\r\n pivot.rotation.x = -Math.PI / 2;\r\n newMesh.parent = pivot;\r\n\r\n newMesh.bakeCurrentTransformIntoVertices();\r\n\r\n // Remove the pivot\r\n newMesh.parent = null;\r\n pivot.dispose();\r\n }\r\n\r\n return newMesh;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"textBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/textBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAgB,MAAM,8BAA8B,CAAC;AAGrE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAyCvD,kBAAkB;AAClB,MAAM,SAAS;IAOX;;OAEG;IACH,YAAY,UAAkB;QATtB,WAAM,GAAY,EAAE,CAAC;QACrB,eAAU,GAAY,EAAE,CAAC;QACzB,WAAM,GAAY,EAAE,CAAC;QAQzB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,CAAS,EAAE,CAAS;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,CAAS,EAAE,CAAS;QACvB,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,GAAW,EAAE,GAAW,EAAE,CAAS,EAAE,CAAS;QAC3D,I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QAChF,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,0BAA0B;QAClG,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,6BAA6B;QACzH,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAEpB,gBAAgB;QAChB,MAAM,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAChD,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;QAChC,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;QAEvB,OAAO,CAAC,gCAAgC,EAAE,CAAC;QAE3C,mBAAmB;QACnB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC","sourcesContent":["import { type Color4 } from \"../../Maths/math.color\";\r\nimport { Path2 } from \"../../Maths/math.path\";\r\nimport { Vector3, type Vector4 } from \"../../Maths/math.vector.pure\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { type Nullable } from \"../../types\";\r\nimport { Mesh } from \"../mesh.pure\";\r\nimport { TransformNode } from \"../transformNode.pure\";\r\nimport { ExtrudePolygon } from \"./polygonBuilder.pure\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let earcut: any;\r\n\r\n/**\r\n * Parser inspired by https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/FontLoader.js\r\n */\r\n\r\n// Interfaces\r\n\r\n/**\r\n * Represents glyph data generated by http://gero3.github.io/facetype.js/\r\n */\r\nexport interface IGlyphData {\r\n /** Commands used to draw (line, move, curve, etc..) */\r\n o: string;\r\n\r\n /** Width */\r\n ha: number;\r\n}\r\n\r\n/**\r\n * Represents font data generated by http://gero3.github.io/facetype.js/\r\n */\r\nexport interface IFontData {\r\n /**\r\n * Font resolution\r\n */\r\n resolution: number;\r\n /** Underline tickness */\r\n underlineThickness: number;\r\n /** Bounding box */\r\n boundingBox: {\r\n yMax: number;\r\n yMin: number;\r\n };\r\n /** List of supported glyphs */\r\n glyphs: { [key: string]: IGlyphData };\r\n}\r\n\r\n// Shape functions\r\nclass ShapePath {\r\n private _paths: Path2[] = [];\r\n private _tempPaths: Path2[] = [];\r\n private _holes: Path2[] = [];\r\n private _currentPath: Path2;\r\n private _resolution: number;\r\n\r\n /** Create the ShapePath used to support glyphs\r\n * @param resolution defines the resolution used to determine the number of points per curve (default is 4)\r\n */\r\n constructor(resolution: number) {\r\n this._resolution = resolution;\r\n }\r\n\r\n /** Move the virtual cursor to a coordinate\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n */\r\n moveTo(x: number, y: number) {\r\n this._currentPath = new Path2(x, y);\r\n this._tempPaths.push(this._currentPath);\r\n }\r\n\r\n /** Draw a line from the virtual cursor to a given coordinate\r\n * @param x defines the x coordinate\r\n * @param y defines the y coordinate\r\n */\r\n lineTo(x: number, y: number) {\r\n this._currentPath.addLineTo(x, y);\r\n }\r\n\r\n /** Create a quadratic curve from the virtual cursor to a given coordinate\r\n * @param cpx defines the x coordinate of the control point\r\n * @param cpy defines the y coordinate of the control point\r\n * @param x defines the x coordinate of the end point\r\n * @param y defines the y coordinate of the end point\r\n */\r\n quadraticCurveTo(cpx: number, cpy: number, x: number, y: number) {\r\n this._currentPath.addQuadraticCurveTo(cpx, cpy, x, y, this._resolution);\r\n }\r\n\r\n /**\r\n * Create a bezier curve from the virtual cursor to a given coordinate\r\n * @param cpx1 defines the x coordinate of the first control point\r\n * @param cpy1 defines the y coordinate of the first control point\r\n * @param cpx2 defines the x coordinate of the second control point\r\n * @param cpy2 defines the y coordinate of the second control point\r\n * @param x defines the x coordinate of the end point\r\n * @param y defines the y coordinate of the end point\r\n */\r\n bezierCurveTo(cpx1: number, cpy1: number, cpx2: number, cpy2: number, x: number, y: number) {\r\n this._currentPath.addBezierCurveTo(cpx1, cpy1, cpx2, cpy2, x, y, this._resolution);\r\n }\r\n\r\n /** Extract holes based on CW / CCW */\r\n extractHoles() {\r\n for (const path of this._tempPaths) {\r\n if (path.area() > 0) {\r\n this._holes.push(path);\r\n } else {\r\n this._paths.push(path);\r\n }\r\n }\r\n\r\n if (!this._paths.length && this._holes.length) {\r\n const temp = this._holes;\r\n this._holes = this._paths;\r\n this._paths = temp;\r\n }\r\n\r\n this._tempPaths.length = 0;\r\n }\r\n\r\n /** Gets the list of paths */\r\n get paths() {\r\n return this._paths;\r\n }\r\n\r\n /** Gets the list of holes */\r\n get holes() {\r\n return this._holes;\r\n }\r\n}\r\n\r\n// Utility functions\r\nfunction CreateShapePath(\r\n char: string,\r\n scale: number,\r\n offsetX: number,\r\n offsetY: number,\r\n resolution: number,\r\n fontData: IFontData\r\n): Nullable<{\r\n offsetX: number;\r\n shapePath: ShapePath;\r\n}> {\r\n const glyph = fontData.glyphs[char] || fontData.glyphs[\"?\"];\r\n\r\n if (!glyph) {\r\n // return if there is no glyph data\r\n return null;\r\n }\r\n\r\n const shapePath = new ShapePath(resolution);\r\n\r\n if (glyph.o) {\r\n const outline = glyph.o.split(\" \");\r\n\r\n for (let i = 0, l = outline.length; i < l;) {\r\n const action = outline[i++];\r\n\r\n switch (action) {\r\n case \"m\": {\r\n // moveTo\r\n const x = parseInt(outline[i++]) * scale + offsetX;\r\n const y = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.moveTo(x, y);\r\n break;\r\n }\r\n case \"l\": {\r\n // lineTo\r\n const x = parseInt(outline[i++]) * scale + offsetX;\r\n const y = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.lineTo(x, y);\r\n break;\r\n }\r\n case \"q\": {\r\n // quadraticCurveTo\r\n const cpx = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy = parseInt(outline[i++]) * scale + offsetY;\r\n const cpx1 = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy1 = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.quadraticCurveTo(cpx1, cpy1, cpx, cpy);\r\n break;\r\n }\r\n case \"b\": {\r\n // bezierCurveTo\r\n const cpx = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy = parseInt(outline[i++]) * scale + offsetY;\r\n const cpx1 = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy1 = parseInt(outline[i++]) * scale + offsetY;\r\n const cpx2 = parseInt(outline[i++]) * scale + offsetX;\r\n const cpy2 = parseInt(outline[i++]) * scale + offsetY;\r\n\r\n shapePath.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, cpx, cpy);\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Extract holes (based on clockwise data)\r\n shapePath.extractHoles();\r\n\r\n return { offsetX: glyph.ha * scale, shapePath: shapePath };\r\n}\r\n\r\n/**\r\n * Creates shape paths from a text and font\r\n * @param text the text\r\n * @param size size of the font\r\n * @param resolution resolution of the font\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @returns array of ShapePath objects\r\n */\r\nexport function CreateTextShapePaths(text: string, size: number, resolution: number, fontData: IFontData) {\r\n const chars = Array.from(text);\r\n const scale = size / fontData.resolution;\r\n const lineHeight = (fontData.boundingBox.yMax - fontData.boundingBox.yMin + fontData.underlineThickness) * scale;\r\n\r\n const shapePaths: ShapePath[] = [];\r\n\r\n let offsetX = 0,\r\n offsetY = 0;\r\n\r\n for (let i = 0; i < chars.length; i++) {\r\n const char = chars[i];\r\n\r\n if (char === \"\\n\") {\r\n offsetX = 0;\r\n offsetY -= lineHeight;\r\n } else {\r\n const ret = CreateShapePath(char, scale, offsetX, offsetY, resolution, fontData);\r\n\r\n if (ret) {\r\n offsetX += ret.offsetX;\r\n shapePaths.push(ret.shapePath);\r\n }\r\n }\r\n }\r\n\r\n return shapePaths;\r\n}\r\n\r\n/**\r\n * Create a text mesh\r\n * @param name defines the name of the mesh\r\n * @param text defines the text to use to build the mesh\r\n * @param fontData defines the font data (can be generated with http://gero3.github.io/facetype.js/)\r\n * @param options defines options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @param earcutInjection can be used to inject your own earcut reference\r\n * @returns a new Mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/text\r\n */\r\nexport function CreateText(\r\n name: string,\r\n text: string,\r\n fontData: IFontData,\r\n options: {\r\n size?: number;\r\n resolution?: number;\r\n depth?: number;\r\n sideOrientation?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n perLetterFaceUV?: (letterIndex: number) => Vector4[];\r\n perLetterFaceColors?: (letterIndex: number) => Color4[];\r\n } = {\r\n size: 50,\r\n resolution: 8,\r\n depth: 1.0,\r\n },\r\n scene: Nullable<Scene> = null,\r\n earcutInjection = earcut\r\n): Nullable<Mesh> {\r\n // First we need to generate the paths\r\n const shapePaths = CreateTextShapePaths(text, options.size || 50, options.resolution || 8, fontData);\r\n\r\n // And extrude them\r\n const meshes: Mesh[] = [];\r\n let letterIndex = 0;\r\n for (const shapePath of shapePaths) {\r\n if (!shapePath.paths.length) {\r\n continue;\r\n }\r\n\r\n const holes = shapePath.holes.slice(); // Copy it as we will update the copy\r\n for (const path of shapePath.paths) {\r\n const holeVectors: Vector3[][] = [];\r\n const shapeVectors: Vector3[] = [];\r\n const points = path.getPoints();\r\n for (const point of points) {\r\n shapeVectors.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane\r\n }\r\n\r\n // Holes\r\n const localHolesCopy = holes.slice();\r\n for (const hole of localHolesCopy) {\r\n const points = hole.getPoints();\r\n\r\n let found = false;\r\n for (const point of points) {\r\n if (path.isPointInside(point)) {\r\n found = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!found) {\r\n continue;\r\n }\r\n\r\n const holePoints: Vector3[] = [];\r\n for (const point of points) {\r\n holePoints.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane\r\n }\r\n holeVectors.push(holePoints);\r\n\r\n // Remove the hole as it was already used\r\n holes.splice(holes.indexOf(hole), 1);\r\n }\r\n\r\n // There is at least a hole but it was unaffected\r\n if (!holeVectors.length && holes.length) {\r\n for (const hole of holes) {\r\n const points = hole.getPoints();\r\n const holePoints: Vector3[] = [];\r\n for (const point of points) {\r\n holePoints.push(new Vector3(point.x, 0, point.y)); // ExtrudePolygon expects data on the xz plane\r\n }\r\n holeVectors.push(holePoints);\r\n }\r\n }\r\n\r\n // Extrusion!\r\n const mesh = ExtrudePolygon(\r\n name,\r\n {\r\n shape: shapeVectors,\r\n holes: holeVectors.length ? holeVectors : undefined,\r\n depth: options.depth || 1.0,\r\n faceUV: options.faceUV || options.perLetterFaceUV?.(letterIndex),\r\n faceColors: options.faceColors || options.perLetterFaceColors?.(letterIndex),\r\n sideOrientation: Mesh._GetDefaultSideOrientation(options.sideOrientation || Mesh.DOUBLESIDE),\r\n },\r\n scene,\r\n earcutInjection\r\n );\r\n meshes.push(mesh);\r\n letterIndex++;\r\n }\r\n }\r\n\r\n // Then we can merge everyone into one single mesh\r\n const newMesh = Mesh.MergeMeshes(meshes, true, true);\r\n\r\n if (newMesh) {\r\n // Move pivot to desired center / bottom / center position\r\n const bbox = newMesh.getBoundingInfo().boundingBox;\r\n newMesh.position.x += -(bbox.minimumWorld.x + bbox.maximumWorld.x) / 2; // Mid X\r\n newMesh.position.y += -(bbox.minimumWorld.y + bbox.maximumWorld.y) / 2; // Mid Z as it will rotate\r\n newMesh.position.z += -(bbox.minimumWorld.z + bbox.maximumWorld.z) / 2 + bbox.extendSize.z; // Bottom Y as it will rotate\r\n newMesh.name = name;\r\n\r\n // Rotate 90° Up\r\n const pivot = new TransformNode(\"pivot\", scene);\r\n pivot.rotation.x = -Math.PI / 2;\r\n newMesh.parent = pivot;\r\n\r\n newMesh.bakeCurrentTransformIntoVertices();\r\n\r\n // Remove the pivot\r\n newMesh.parent = null;\r\n pivot.dispose();\r\n }\r\n\r\n return newMesh;\r\n}\r\n"]}
|
|
@@ -1,83 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { type Scene } from "../../scene.js";
|
|
3
|
-
import { Vector4 } from "../../Maths/math.vector.pure.js";
|
|
4
|
-
import { Color4 } from "../../Maths/math.color.pure.js";
|
|
5
|
-
import { Mesh } from "../mesh.pure.js";
|
|
6
|
-
import { VertexData } from "../mesh.vertexData.js";
|
|
7
|
-
/**
|
|
8
|
-
* Creates the VertexData for a tiled box
|
|
9
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box
|
|
10
|
-
* @param options an object used to set the following optional parameters for the tiled box, required but can be empty
|
|
11
|
-
* * pattern sets the rotation or reflection pattern for the tiles,
|
|
12
|
-
* * size of the box
|
|
13
|
-
* * width of the box, overwrites size
|
|
14
|
-
* * height of the box, overwrites size
|
|
15
|
-
* * depth of the box, overwrites size
|
|
16
|
-
* * tileSize sets the size of a tile
|
|
17
|
-
* * tileWidth sets the tile width and overwrites tileSize
|
|
18
|
-
* * tileHeight sets the tile width and overwrites tileSize
|
|
19
|
-
* * faceUV an array of 6 Vector4 elements used to set different images to each box side
|
|
20
|
-
* * faceColors an array of 6 Color4 elements used to set different colors to each box side
|
|
21
|
-
* * alignHorizontal places whole tiles aligned to the center, left or right of a row
|
|
22
|
-
* * alignVertical places whole tiles aligned to the center, left or right of a column
|
|
23
|
-
* * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
|
|
24
|
-
* @returns the VertexData of the TiledBox
|
|
25
|
-
*/
|
|
26
|
-
export declare function CreateTiledBoxVertexData(options: {
|
|
27
|
-
pattern?: number;
|
|
28
|
-
size?: number;
|
|
29
|
-
width?: number;
|
|
30
|
-
height?: number;
|
|
31
|
-
depth?: number;
|
|
32
|
-
tileSize?: number;
|
|
33
|
-
tileWidth?: number;
|
|
34
|
-
tileHeight?: number;
|
|
35
|
-
faceUV?: Vector4[];
|
|
36
|
-
faceColors?: Color4[];
|
|
37
|
-
alignHorizontal?: number;
|
|
38
|
-
alignVertical?: number;
|
|
39
|
-
sideOrientation?: number;
|
|
40
|
-
}): VertexData;
|
|
41
|
-
/**
|
|
42
|
-
* Creates a tiled box mesh
|
|
43
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box
|
|
44
|
-
* @param name defines the name of the mesh
|
|
45
|
-
* @param options an object used to set the following optional parameters for the tiled box, required but can be empty
|
|
46
|
-
* * pattern sets the rotation or reflection pattern for the tiles,
|
|
47
|
-
* * size of the box
|
|
48
|
-
* * width of the box, overwrites size
|
|
49
|
-
* * height of the box, overwrites size
|
|
50
|
-
* * depth of the box, overwrites size
|
|
51
|
-
* * tileSize sets the size of a tile
|
|
52
|
-
* * tileWidth sets the tile width and overwrites tileSize
|
|
53
|
-
* * tileHeight sets the tile width and overwrites tileSize
|
|
54
|
-
* * faceUV an array of 6 Vector4 elements used to set different images to each box side
|
|
55
|
-
* * faceColors an array of 6 Color3 elements used to set different colors to each box side
|
|
56
|
-
* * alignHorizontal places whole tiles aligned to the center, left or right of a row
|
|
57
|
-
* * alignVertical places whole tiles aligned to the center, left or right of a column
|
|
58
|
-
* * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
|
|
59
|
-
* @param scene defines the hosting scene
|
|
60
|
-
* @returns the box mesh
|
|
61
|
-
*/
|
|
62
|
-
export declare function CreateTiledBox(name: string, options: {
|
|
63
|
-
pattern?: number;
|
|
64
|
-
width?: number;
|
|
65
|
-
height?: number;
|
|
66
|
-
depth?: number;
|
|
67
|
-
tileSize?: number;
|
|
68
|
-
tileWidth?: number;
|
|
69
|
-
tileHeight?: number;
|
|
70
|
-
alignHorizontal?: number;
|
|
71
|
-
alignVertical?: number;
|
|
72
|
-
faceUV?: Vector4[];
|
|
73
|
-
faceColors?: Color4[];
|
|
74
|
-
sideOrientation?: number;
|
|
75
|
-
updatable?: boolean;
|
|
76
|
-
}, scene?: Nullable<Scene>): Mesh;
|
|
77
|
-
/**
|
|
78
|
-
* Class containing static functions to help procedurally build meshes
|
|
79
|
-
* @deprecated use CreateTiledBox instead
|
|
80
|
-
*/
|
|
81
|
-
export declare const TiledBoxBuilder: {
|
|
82
|
-
CreateTiledBox: typeof CreateTiledBox;
|
|
83
|
-
};
|
|
1
|
+
export * from "./tiledBoxBuilder.pure.js";
|
|
@@ -1,216 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { VertexData } from "../mesh.vertexData.js";
|
|
5
|
-
import { CreateTiledPlaneVertexData } from "./tiledPlaneBuilder.js";
|
|
6
|
-
import { useOpenGLOrientationForUV } from "../../Compat/compatibilityOptions.js";
|
|
7
|
-
const OP_ADD = 1;
|
|
8
|
-
const OP_SUB = -1;
|
|
9
|
-
/**
|
|
10
|
-
* Creates the VertexData for a tiled box
|
|
11
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box
|
|
12
|
-
* @param options an object used to set the following optional parameters for the tiled box, required but can be empty
|
|
13
|
-
* * pattern sets the rotation or reflection pattern for the tiles,
|
|
14
|
-
* * size of the box
|
|
15
|
-
* * width of the box, overwrites size
|
|
16
|
-
* * height of the box, overwrites size
|
|
17
|
-
* * depth of the box, overwrites size
|
|
18
|
-
* * tileSize sets the size of a tile
|
|
19
|
-
* * tileWidth sets the tile width and overwrites tileSize
|
|
20
|
-
* * tileHeight sets the tile width and overwrites tileSize
|
|
21
|
-
* * faceUV an array of 6 Vector4 elements used to set different images to each box side
|
|
22
|
-
* * faceColors an array of 6 Color4 elements used to set different colors to each box side
|
|
23
|
-
* * alignHorizontal places whole tiles aligned to the center, left or right of a row
|
|
24
|
-
* * alignVertical places whole tiles aligned to the center, left or right of a column
|
|
25
|
-
* * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
|
|
26
|
-
* @returns the VertexData of the TiledBox
|
|
27
|
-
*/
|
|
28
|
-
export function CreateTiledBoxVertexData(options) {
|
|
29
|
-
const nbFaces = 6;
|
|
30
|
-
const faceUV = options.faceUV || new Array(6);
|
|
31
|
-
const faceColors = options.faceColors;
|
|
32
|
-
const flipTile = options.pattern || Mesh.NO_FLIP;
|
|
33
|
-
const width = options.width || options.size || 1;
|
|
34
|
-
const height = options.height || options.size || 1;
|
|
35
|
-
const depth = options.depth || options.size || 1;
|
|
36
|
-
const tileWidth = options.tileWidth || options.tileSize || 1;
|
|
37
|
-
const tileHeight = options.tileHeight || options.tileSize || 1;
|
|
38
|
-
const alignH = options.alignHorizontal || 0;
|
|
39
|
-
const alignV = options.alignVertical || 0;
|
|
40
|
-
const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
|
|
41
|
-
// default face colors and UV if undefined
|
|
42
|
-
for (let f = 0; f < nbFaces; f++) {
|
|
43
|
-
if (faceUV[f] === undefined) {
|
|
44
|
-
faceUV[f] = new Vector4(0, 0, 1, 1);
|
|
45
|
-
}
|
|
46
|
-
if (faceColors && faceColors[f] === undefined) {
|
|
47
|
-
faceColors[f] = new Color4(1, 1, 1, 1);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const halfWidth = width / 2;
|
|
51
|
-
const halfHeight = height / 2;
|
|
52
|
-
const halfDepth = depth / 2;
|
|
53
|
-
const faceVertexData = [];
|
|
54
|
-
for (let f = 0; f < 2; f++) {
|
|
55
|
-
//front and back
|
|
56
|
-
faceVertexData[f] = CreateTiledPlaneVertexData({
|
|
57
|
-
pattern: flipTile,
|
|
58
|
-
tileWidth: tileWidth,
|
|
59
|
-
tileHeight: tileHeight,
|
|
60
|
-
width: width,
|
|
61
|
-
height: height,
|
|
62
|
-
alignVertical: alignV,
|
|
63
|
-
alignHorizontal: alignH,
|
|
64
|
-
sideOrientation: sideOrientation,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
for (let f = 2; f < 4; f++) {
|
|
68
|
-
//sides
|
|
69
|
-
faceVertexData[f] = CreateTiledPlaneVertexData({
|
|
70
|
-
pattern: flipTile,
|
|
71
|
-
tileWidth: tileWidth,
|
|
72
|
-
tileHeight: tileHeight,
|
|
73
|
-
width: depth,
|
|
74
|
-
height: height,
|
|
75
|
-
alignVertical: alignV,
|
|
76
|
-
alignHorizontal: alignH,
|
|
77
|
-
sideOrientation: sideOrientation,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
let baseAlignV = alignV;
|
|
81
|
-
if (alignV === Mesh.BOTTOM) {
|
|
82
|
-
baseAlignV = Mesh.TOP;
|
|
83
|
-
}
|
|
84
|
-
else if (alignV === Mesh.TOP) {
|
|
85
|
-
baseAlignV = Mesh.BOTTOM;
|
|
86
|
-
}
|
|
87
|
-
for (let f = 4; f < 6; f++) {
|
|
88
|
-
//top and bottom
|
|
89
|
-
faceVertexData[f] = CreateTiledPlaneVertexData({
|
|
90
|
-
pattern: flipTile,
|
|
91
|
-
tileWidth: tileWidth,
|
|
92
|
-
tileHeight: tileHeight,
|
|
93
|
-
width: width,
|
|
94
|
-
height: depth,
|
|
95
|
-
alignVertical: baseAlignV,
|
|
96
|
-
alignHorizontal: alignH,
|
|
97
|
-
sideOrientation: sideOrientation,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
const positions = [];
|
|
101
|
-
const normals = [];
|
|
102
|
-
let uvs = [];
|
|
103
|
-
let indices = [];
|
|
104
|
-
const colors = [];
|
|
105
|
-
const facePositions = [];
|
|
106
|
-
const faceNormals = [];
|
|
107
|
-
const newFaceUV = [];
|
|
108
|
-
let lu;
|
|
109
|
-
let li = 0;
|
|
110
|
-
for (let f = 0; f < nbFaces; f++) {
|
|
111
|
-
const len = faceVertexData[f].positions.length;
|
|
112
|
-
facePositions[f] = [];
|
|
113
|
-
faceNormals[f] = [];
|
|
114
|
-
for (let p = 0; p < len / 3; p++) {
|
|
115
|
-
facePositions[f].push(new Vector3(faceVertexData[f].positions[3 * p], faceVertexData[f].positions[3 * p + 1], faceVertexData[f].positions[3 * p + 2]));
|
|
116
|
-
faceNormals[f].push(new Vector3(faceVertexData[f].normals[3 * p], faceVertexData[f].normals[3 * p + 1], faceVertexData[f].normals[3 * p + 2]));
|
|
117
|
-
}
|
|
118
|
-
// uvs
|
|
119
|
-
lu = faceVertexData[f].uvs.length;
|
|
120
|
-
newFaceUV[f] = [];
|
|
121
|
-
for (let i = 0; i < lu; i += 2) {
|
|
122
|
-
newFaceUV[f][i] = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * faceVertexData[f].uvs[i];
|
|
123
|
-
newFaceUV[f][i + 1] = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * faceVertexData[f].uvs[i + 1];
|
|
124
|
-
if (useOpenGLOrientationForUV) {
|
|
125
|
-
newFaceUV[f][i + 1] = 1.0 - newFaceUV[f][i + 1];
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
uvs = uvs.concat(newFaceUV[f]);
|
|
129
|
-
indices = indices.concat(faceVertexData[f].indices.map((x) => x + li));
|
|
130
|
-
li += facePositions[f].length;
|
|
131
|
-
if (faceColors) {
|
|
132
|
-
const color = faceColors[f];
|
|
133
|
-
for (let p = 0; p < facePositions[f].length; p++) {
|
|
134
|
-
colors.push(color.r, color.g, color.b, color.a);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// Define transforms for each face
|
|
139
|
-
const faceTransforms = [
|
|
140
|
-
// FRONT
|
|
141
|
-
{ m: Matrix.RotationY(Math.PI), t: new Vector3(0, 0, halfDepth), op: OP_ADD },
|
|
142
|
-
// BACK
|
|
143
|
-
{ m: Matrix.Identity(), t: new Vector3(0, 0, halfDepth), op: OP_SUB },
|
|
144
|
-
// RIGHT
|
|
145
|
-
{ m: Matrix.RotationY(-Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_ADD },
|
|
146
|
-
// LEFT
|
|
147
|
-
{ m: Matrix.RotationY(Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_SUB },
|
|
148
|
-
// TOP
|
|
149
|
-
{ m: Matrix.RotationX(Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_ADD },
|
|
150
|
-
// BOTTOM
|
|
151
|
-
{ m: Matrix.RotationX(-Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_SUB },
|
|
152
|
-
];
|
|
153
|
-
// Assemble positions and normals
|
|
154
|
-
for (let f = 0; f < nbFaces; f++) {
|
|
155
|
-
const { m, t, op } = faceTransforms[f];
|
|
156
|
-
for (const v of facePositions[f]) {
|
|
157
|
-
const p = Vector3.TransformCoordinates(v, m);
|
|
158
|
-
const final = op === OP_ADD ? p.add(t) : p.subtract(t);
|
|
159
|
-
positions.push(final.x, final.y, final.z);
|
|
160
|
-
}
|
|
161
|
-
for (const n of faceNormals[f]) {
|
|
162
|
-
const nn = Vector3.TransformNormal(n, m);
|
|
163
|
-
normals.push(nn.x, nn.y, nn.z);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
// Result
|
|
167
|
-
const vertexData = new VertexData();
|
|
168
|
-
vertexData.indices = indices;
|
|
169
|
-
vertexData.positions = positions;
|
|
170
|
-
vertexData.normals = normals;
|
|
171
|
-
vertexData.uvs = uvs;
|
|
172
|
-
if (faceColors) {
|
|
173
|
-
const totalColors = sideOrientation === VertexData.DOUBLESIDE ? colors.concat(colors) : colors;
|
|
174
|
-
vertexData.colors = totalColors;
|
|
175
|
-
}
|
|
176
|
-
return vertexData;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Creates a tiled box mesh
|
|
180
|
-
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box
|
|
181
|
-
* @param name defines the name of the mesh
|
|
182
|
-
* @param options an object used to set the following optional parameters for the tiled box, required but can be empty
|
|
183
|
-
* * pattern sets the rotation or reflection pattern for the tiles,
|
|
184
|
-
* * size of the box
|
|
185
|
-
* * width of the box, overwrites size
|
|
186
|
-
* * height of the box, overwrites size
|
|
187
|
-
* * depth of the box, overwrites size
|
|
188
|
-
* * tileSize sets the size of a tile
|
|
189
|
-
* * tileWidth sets the tile width and overwrites tileSize
|
|
190
|
-
* * tileHeight sets the tile width and overwrites tileSize
|
|
191
|
-
* * faceUV an array of 6 Vector4 elements used to set different images to each box side
|
|
192
|
-
* * faceColors an array of 6 Color3 elements used to set different colors to each box side
|
|
193
|
-
* * alignHorizontal places whole tiles aligned to the center, left or right of a row
|
|
194
|
-
* * alignVertical places whole tiles aligned to the center, left or right of a column
|
|
195
|
-
* * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
|
|
196
|
-
* @param scene defines the hosting scene
|
|
197
|
-
* @returns the box mesh
|
|
198
|
-
*/
|
|
199
|
-
export function CreateTiledBox(name, options, scene = null) {
|
|
200
|
-
const box = new Mesh(name, scene);
|
|
201
|
-
options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);
|
|
202
|
-
box._originalBuilderSideOrientation = options.sideOrientation;
|
|
203
|
-
const vertexData = CreateTiledBoxVertexData(options);
|
|
204
|
-
vertexData.applyToMesh(box, options.updatable);
|
|
205
|
-
return box;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Class containing static functions to help procedurally build meshes
|
|
209
|
-
* @deprecated use CreateTiledBox instead
|
|
210
|
-
*/
|
|
211
|
-
export const TiledBoxBuilder = {
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
213
|
-
CreateTiledBox,
|
|
214
|
-
};
|
|
215
|
-
VertexData.CreateTiledBox = CreateTiledBoxVertexData;
|
|
1
|
+
export * from "./tiledBoxBuilder.pure.js";
|
|
2
|
+
import { RegisterTiledBoxBuilder } from "./tiledBoxBuilder.pure.js";
|
|
3
|
+
RegisterTiledBoxBuilder();
|
|
216
4
|
//# sourceMappingURL=tiledBoxBuilder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiledBoxBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/tiledBoxBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC;AAElB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAcxC;IACG,MAAM,OAAO,GAAG,CAAC,CAAC;IAElB,MAAM,MAAM,GAAc,OAAO,CAAC,MAAM,IAAI,IAAI,KAAK,CAAU,CAAC,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAEtC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC;IAEjD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;IACnD,MAAM,KAAK,GAAG,OAA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OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,gEAAgE;IAChE,cAAc;CACjB,CAAC;AAEF,UAAU,CAAC,cAAc,GAAG,wBAAwB,CAAC","sourcesContent":["import { type Nullable } from \"../../types\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { Matrix, Vector3, Vector4 } from \"../../Maths/math.vector.pure\";\r\nimport { Color4 } from \"../../Maths/math.color.pure\";\r\nimport { Mesh } from \"../mesh.pure\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { CreateTiledPlaneVertexData } from \"./tiledPlaneBuilder\";\r\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions\";\r\n\r\nconst OP_ADD = 1;\r\nconst OP_SUB = -1;\r\n\r\n/**\r\n * Creates the VertexData for a tiled box\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box\r\n * @param options an object used to set the following optional parameters for the tiled box, required but can be empty\r\n * * pattern sets the rotation or reflection pattern for the tiles,\r\n * * size of the box\r\n * * width of the box, overwrites size\r\n * * height of the box, overwrites size\r\n * * depth of the box, overwrites size\r\n * * tileSize sets the size of a tile\r\n * * tileWidth sets the tile width and overwrites tileSize\r\n * * tileHeight sets the tile width and overwrites tileSize\r\n * * faceUV an array of 6 Vector4 elements used to set different images to each box side\r\n * * faceColors an array of 6 Color4 elements used to set different colors to each box side\r\n * * alignHorizontal places whole tiles aligned to the center, left or right of a row\r\n * * alignVertical places whole tiles aligned to the center, left or right of a column\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @returns the VertexData of the TiledBox\r\n */\r\nexport function CreateTiledBoxVertexData(options: {\r\n pattern?: number;\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n tileSize?: number;\r\n tileWidth?: number;\r\n tileHeight?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n alignHorizontal?: number;\r\n alignVertical?: number;\r\n sideOrientation?: number;\r\n}): VertexData {\r\n const nbFaces = 6;\r\n\r\n const faceUV: Vector4[] = options.faceUV || new Array<Vector4>(6);\r\n const faceColors = options.faceColors;\r\n\r\n const flipTile = options.pattern || Mesh.NO_FLIP;\r\n\r\n const width = options.width || options.size || 1;\r\n const height = options.height || options.size || 1;\r\n const depth = options.depth || options.size || 1;\r\n const tileWidth = options.tileWidth || options.tileSize || 1;\r\n const tileHeight = options.tileHeight || options.tileSize || 1;\r\n const alignH = options.alignHorizontal || 0;\r\n const alignV = options.alignVertical || 0;\r\n\r\n const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\r\n\r\n // default face colors and UV if undefined\r\n for (let f = 0; f < nbFaces; f++) {\r\n if (faceUV[f] === undefined) {\r\n faceUV[f] = new Vector4(0, 0, 1, 1);\r\n }\r\n if (faceColors && faceColors[f] === undefined) {\r\n faceColors[f] = new Color4(1, 1, 1, 1);\r\n }\r\n }\r\n\r\n const halfWidth = width / 2;\r\n const halfHeight = height / 2;\r\n const halfDepth = depth / 2;\r\n\r\n const faceVertexData: Array<VertexData> = [];\r\n\r\n for (let f = 0; f < 2; f++) {\r\n //front and back\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: width,\r\n height: height,\r\n alignVertical: alignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n for (let f = 2; f < 4; f++) {\r\n //sides\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: depth,\r\n height: height,\r\n alignVertical: alignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n let baseAlignV = alignV;\r\n if (alignV === Mesh.BOTTOM) {\r\n baseAlignV = Mesh.TOP;\r\n } else if (alignV === Mesh.TOP) {\r\n baseAlignV = Mesh.BOTTOM;\r\n }\r\n\r\n for (let f = 4; f < 6; f++) {\r\n //top and bottom\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: width,\r\n height: depth,\r\n alignVertical: baseAlignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n const positions: Array<number> = [];\r\n const normals: Array<number> = [];\r\n let uvs: Array<number> = [];\r\n let indices: Array<number> = [];\r\n const colors: Array<number> = [];\r\n const facePositions: Array<Array<Vector3>> = [];\r\n const faceNormals: Array<Array<Vector3>> = [];\r\n\r\n const newFaceUV: Array<Array<number>> = [];\r\n let lu: number;\r\n\r\n let li: number = 0;\r\n\r\n for (let f = 0; f < nbFaces; f++) {\r\n const len = faceVertexData[f].positions!.length;\r\n facePositions[f] = [];\r\n faceNormals[f] = [];\r\n for (let p = 0; p < len / 3; p++) {\r\n facePositions[f].push(new Vector3(faceVertexData[f].positions![3 * p], faceVertexData[f].positions![3 * p + 1], faceVertexData[f].positions![3 * p + 2]));\r\n faceNormals[f].push(new Vector3(faceVertexData[f].normals![3 * p], faceVertexData[f].normals![3 * p + 1], faceVertexData[f].normals![3 * p + 2]));\r\n }\r\n // uvs\r\n lu = faceVertexData[f].uvs!.length;\r\n newFaceUV[f] = [];\r\n for (let i = 0; i < lu; i += 2) {\r\n newFaceUV[f][i] = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * faceVertexData[f].uvs![i];\r\n newFaceUV[f][i + 1] = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * faceVertexData[f].uvs![i + 1];\r\n\r\n if (useOpenGLOrientationForUV) {\r\n newFaceUV[f][i + 1] = 1.0 - newFaceUV[f][i + 1];\r\n }\r\n }\r\n uvs = uvs.concat(newFaceUV[f]);\r\n\r\n indices = indices.concat(<Array<number>>faceVertexData[f].indices!.map((x: number) => x + li));\r\n li += facePositions[f].length;\r\n if (faceColors) {\r\n const color = faceColors[f];\r\n for (let p = 0; p < facePositions[f].length; p++) {\r\n colors.push(color.r, color.g, color.b, color.a);\r\n }\r\n }\r\n }\r\n\r\n // Define transforms for each face\r\n const faceTransforms = [\r\n // FRONT\r\n { m: Matrix.RotationY(Math.PI), t: new Vector3(0, 0, halfDepth), op: OP_ADD },\r\n // BACK\r\n { m: Matrix.Identity(), t: new Vector3(0, 0, halfDepth), op: OP_SUB },\r\n // RIGHT\r\n { m: Matrix.RotationY(-Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_ADD },\r\n // LEFT\r\n { m: Matrix.RotationY(Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_SUB },\r\n // TOP\r\n { m: Matrix.RotationX(Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_ADD },\r\n // BOTTOM\r\n { m: Matrix.RotationX(-Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_SUB },\r\n ];\r\n\r\n // Assemble positions and normals\r\n for (let f = 0; f < nbFaces; f++) {\r\n const { m, t, op } = faceTransforms[f];\r\n\r\n for (const v of facePositions[f]) {\r\n const p = Vector3.TransformCoordinates(v, m);\r\n const final = op === OP_ADD ? p.add(t) : p.subtract(t);\r\n positions.push(final.x, final.y, final.z);\r\n }\r\n\r\n for (const n of faceNormals[f]) {\r\n const nn = Vector3.TransformNormal(n, m);\r\n normals.push(nn.x, nn.y, nn.z);\r\n }\r\n }\r\n\r\n // Result\r\n const vertexData = new VertexData();\r\n\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n vertexData.normals = normals;\r\n vertexData.uvs = uvs;\r\n\r\n if (faceColors) {\r\n const totalColors = sideOrientation === VertexData.DOUBLESIDE ? colors.concat(colors) : colors;\r\n vertexData.colors = totalColors;\r\n }\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates a tiled box mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box\r\n * @param name defines the name of the mesh\r\n * @param options an object used to set the following optional parameters for the tiled box, required but can be empty\r\n * * pattern sets the rotation or reflection pattern for the tiles,\r\n * * size of the box\r\n * * width of the box, overwrites size\r\n * * height of the box, overwrites size\r\n * * depth of the box, overwrites size\r\n * * tileSize sets the size of a tile\r\n * * tileWidth sets the tile width and overwrites tileSize\r\n * * tileHeight sets the tile width and overwrites tileSize\r\n * * faceUV an array of 6 Vector4 elements used to set different images to each box side\r\n * * faceColors an array of 6 Color3 elements used to set different colors to each box side\r\n * * alignHorizontal places whole tiles aligned to the center, left or right of a row\r\n * * alignVertical places whole tiles aligned to the center, left or right of a column\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @param scene defines the hosting scene\r\n * @returns the box mesh\r\n */\r\nexport function CreateTiledBox(\r\n name: string,\r\n options: {\r\n pattern?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n tileSize?: number;\r\n tileWidth?: number;\r\n tileHeight?: number;\r\n alignHorizontal?: number;\r\n alignVertical?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n sideOrientation?: number;\r\n updatable?: boolean;\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const box = new Mesh(name, scene);\r\n\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n box._originalBuilderSideOrientation = options.sideOrientation;\r\n\r\n const vertexData = CreateTiledBoxVertexData(options);\r\n\r\n vertexData.applyToMesh(box, options.updatable);\r\n\r\n return box;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use CreateTiledBox instead\r\n */\r\nexport const TiledBoxBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateTiledBox,\r\n};\r\n\r\nVertexData.CreateTiledBox = CreateTiledBoxVertexData;\r\n"]}
|
|
1
|
+
{"version":3,"file":"tiledBoxBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/tiledBoxBuilder.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,uBAAuB,EAAE,CAAC","sourcesContent":["export * from \"./tiledBoxBuilder.pure\";\n\nimport { RegisterTiledBoxBuilder } from \"./tiledBoxBuilder.pure\";\nRegisterTiledBoxBuilder();\n"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** This file must only contain pure code and pure imports */
|
|
2
|
+
import { type Nullable } from "../../types.js";
|
|
3
|
+
import { type Scene } from "../../scene.js";
|
|
4
|
+
import { Vector4 } from "../../Maths/math.vector.pure.js";
|
|
5
|
+
import { Color4 } from "../../Maths/math.color.pure.js";
|
|
6
|
+
import { Mesh } from "../mesh.pure.js";
|
|
7
|
+
import { VertexData } from "../mesh.vertexData.js";
|
|
8
|
+
/**
|
|
9
|
+
* Creates the VertexData for a tiled box
|
|
10
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box
|
|
11
|
+
* @param options an object used to set the following optional parameters for the tiled box, required but can be empty
|
|
12
|
+
* * pattern sets the rotation or reflection pattern for the tiles,
|
|
13
|
+
* * size of the box
|
|
14
|
+
* * width of the box, overwrites size
|
|
15
|
+
* * height of the box, overwrites size
|
|
16
|
+
* * depth of the box, overwrites size
|
|
17
|
+
* * tileSize sets the size of a tile
|
|
18
|
+
* * tileWidth sets the tile width and overwrites tileSize
|
|
19
|
+
* * tileHeight sets the tile width and overwrites tileSize
|
|
20
|
+
* * faceUV an array of 6 Vector4 elements used to set different images to each box side
|
|
21
|
+
* * faceColors an array of 6 Color4 elements used to set different colors to each box side
|
|
22
|
+
* * alignHorizontal places whole tiles aligned to the center, left or right of a row
|
|
23
|
+
* * alignVertical places whole tiles aligned to the center, left or right of a column
|
|
24
|
+
* * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
|
|
25
|
+
* @returns the VertexData of the TiledBox
|
|
26
|
+
*/
|
|
27
|
+
export declare function CreateTiledBoxVertexData(options: {
|
|
28
|
+
pattern?: number;
|
|
29
|
+
size?: number;
|
|
30
|
+
width?: number;
|
|
31
|
+
height?: number;
|
|
32
|
+
depth?: number;
|
|
33
|
+
tileSize?: number;
|
|
34
|
+
tileWidth?: number;
|
|
35
|
+
tileHeight?: number;
|
|
36
|
+
faceUV?: Vector4[];
|
|
37
|
+
faceColors?: Color4[];
|
|
38
|
+
alignHorizontal?: number;
|
|
39
|
+
alignVertical?: number;
|
|
40
|
+
sideOrientation?: number;
|
|
41
|
+
}): VertexData;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a tiled box mesh
|
|
44
|
+
* @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box
|
|
45
|
+
* @param name defines the name of the mesh
|
|
46
|
+
* @param options an object used to set the following optional parameters for the tiled box, required but can be empty
|
|
47
|
+
* * pattern sets the rotation or reflection pattern for the tiles,
|
|
48
|
+
* * size of the box
|
|
49
|
+
* * width of the box, overwrites size
|
|
50
|
+
* * height of the box, overwrites size
|
|
51
|
+
* * depth of the box, overwrites size
|
|
52
|
+
* * tileSize sets the size of a tile
|
|
53
|
+
* * tileWidth sets the tile width and overwrites tileSize
|
|
54
|
+
* * tileHeight sets the tile width and overwrites tileSize
|
|
55
|
+
* * faceUV an array of 6 Vector4 elements used to set different images to each box side
|
|
56
|
+
* * faceColors an array of 6 Color3 elements used to set different colors to each box side
|
|
57
|
+
* * alignHorizontal places whole tiles aligned to the center, left or right of a row
|
|
58
|
+
* * alignVertical places whole tiles aligned to the center, left or right of a column
|
|
59
|
+
* * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
|
|
60
|
+
* @param scene defines the hosting scene
|
|
61
|
+
* @returns the box mesh
|
|
62
|
+
*/
|
|
63
|
+
export declare function CreateTiledBox(name: string, options: {
|
|
64
|
+
pattern?: number;
|
|
65
|
+
width?: number;
|
|
66
|
+
height?: number;
|
|
67
|
+
depth?: number;
|
|
68
|
+
tileSize?: number;
|
|
69
|
+
tileWidth?: number;
|
|
70
|
+
tileHeight?: number;
|
|
71
|
+
alignHorizontal?: number;
|
|
72
|
+
alignVertical?: number;
|
|
73
|
+
faceUV?: Vector4[];
|
|
74
|
+
faceColors?: Color4[];
|
|
75
|
+
sideOrientation?: number;
|
|
76
|
+
updatable?: boolean;
|
|
77
|
+
}, scene?: Nullable<Scene>): Mesh;
|
|
78
|
+
/**
|
|
79
|
+
* Class containing static functions to help procedurally build meshes
|
|
80
|
+
* @deprecated use CreateTiledBox instead
|
|
81
|
+
*/
|
|
82
|
+
export declare const TiledBoxBuilder: {
|
|
83
|
+
CreateTiledBox: typeof CreateTiledBox;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Register side effects for the tiled box builder.
|
|
87
|
+
* Safe to call multiple times; only the first call has an effect.
|
|
88
|
+
*/
|
|
89
|
+
export declare function RegisterTiledBoxBuilder(): void;
|