@babylonjs/core 5.0.0-beta.8 → 5.0.0-rc.1
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/Actions/actionEvent.d.ts +3 -4
- package/Actions/actionEvent.js.map +1 -1
- package/Animations/animation.d.ts +4 -4
- package/Animations/animation.js +4 -4
- package/Animations/animation.js.map +1 -1
- package/Audio/sound.d.ts +12 -6
- package/Audio/sound.js +48 -24
- package/Audio/sound.js.map +1 -1
- package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Cameras/Inputs/BaseCameraPointersInput.d.ts +1 -0
- package/Cameras/Inputs/BaseCameraPointersInput.js +4 -3
- package/Cameras/Inputs/BaseCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js +7 -5
- package/Cameras/Inputs/arcRotateCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/followCameraMouseWheelInput.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/arcRotateCamera.js +3 -3
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/DeviceInput/Helpers/eventFactory.d.ts +6 -6
- package/DeviceInput/Helpers/eventFactory.js +34 -16
- package/DeviceInput/Helpers/eventFactory.js.map +1 -1
- package/DeviceInput/InputDevices/deviceEnums.d.ts +26 -3
- package/DeviceInput/InputDevices/deviceEnums.js +31 -7
- package/DeviceInput/InputDevices/deviceEnums.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSource.d.ts +11 -3
- package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSourceManager.d.ts +28 -10
- package/DeviceInput/InputDevices/deviceSourceManager.js +131 -7
- package/DeviceInput/InputDevices/deviceSourceManager.js.map +1 -1
- package/DeviceInput/InputDevices/deviceTypes.d.ts +1 -1
- package/DeviceInput/InputDevices/deviceTypes.js.map +1 -1
- package/DeviceInput/InputDevices/inputInterfaces.d.ts +3 -28
- package/DeviceInput/InputDevices/inputInterfaces.js.map +1 -1
- package/DeviceInput/InputDevices/internalDeviceSourceManager.d.ts +15 -30
- package/DeviceInput/InputDevices/internalDeviceSourceManager.js +40 -110
- package/DeviceInput/InputDevices/internalDeviceSourceManager.js.map +1 -1
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.d.ts +3 -2
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.js +7 -13
- package/DeviceInput/InputDevices/nativeDeviceInputSystem.js.map +1 -1
- package/DeviceInput/InputDevices/webDeviceInputSystem.d.ts +11 -8
- package/DeviceInput/InputDevices/webDeviceInputSystem.js +116 -110
- package/DeviceInput/InputDevices/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.query.d.ts +7 -0
- package/Engines/Extensions/engine.query.js +12 -0
- package/Engines/Extensions/engine.query.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.d.ts +5 -0
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +7 -0
- package/Engines/Extensions/engine.views.js +12 -0
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/engine.d.ts +6 -2
- package/Engines/engine.js.map +1 -1
- package/Engines/index.d.ts +1 -0
- package/Engines/index.js +1 -0
- package/Engines/index.js.map +1 -1
- package/Engines/nativeEngine.js +12 -11
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +2 -2
- package/Engines/webgpuEngine.js.map +1 -1
- package/Events/deviceInputEvents.d.ts +17 -18
- package/Events/deviceInputEvents.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Helpers/environmentHelper.js +2 -2
- package/Helpers/environmentHelper.js.map +1 -1
- package/Inputs/scene.inputManager.d.ts +0 -1
- package/Inputs/scene.inputManager.js +54 -28
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Layers/effectLayer.d.ts +1 -0
- package/Layers/effectLayer.js +24 -0
- package/Layers/effectLayer.js.map +1 -1
- package/Loading/sceneLoader.js +4 -3
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.d.ts +6 -2
- package/Materials/Node/Blocks/Dual/textureBlock.js +50 -8
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/dynamicTexture.d.ts +1 -1
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/materialPluginBase.d.ts +5 -0
- package/Materials/materialPluginBase.js +5 -0
- package/Materials/materialPluginBase.js.map +1 -1
- package/Materials/materialPluginEvent.d.ts +1 -0
- package/Materials/materialPluginEvent.js.map +1 -1
- package/Materials/materialPluginManager.d.ts +1 -0
- package/Materials/materialPluginManager.js +20 -15
- package/Materials/materialPluginManager.js.map +1 -1
- package/Materials/standardMaterial.js +1 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.vector.d.ts +5 -0
- package/Maths/math.vector.js +11 -0
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/polygonBuilder.js +2 -1
- package/Meshes/Builders/polygonBuilder.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/instancedMesh.js +7 -4
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/mesh.js +21 -22
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +2 -2
- package/Meshes/mesh.vertexData.js +100 -76
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Meshes/transformNode.d.ts +0 -2
- package/Meshes/transformNode.js +6 -5
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/error.d.ts +51 -0
- package/Misc/error.js +66 -0
- package/Misc/error.js.map +1 -0
- package/Misc/fileTools.d.ts +4 -4
- package/Misc/fileTools.js +30 -16
- package/Misc/fileTools.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.d.ts +8 -7
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/videoRecorder.d.ts +1 -1
- package/Misc/videoRecorder.js +1 -1
- package/Misc/videoRecorder.js.map +1 -1
- package/Morph/morphTarget.d.ts +2 -1
- package/Morph/morphTarget.js +5 -1
- package/Morph/morphTarget.js.map +1 -1
- package/Morph/morphTargetManager.js +1 -1
- package/Morph/morphTargetManager.js.map +1 -1
- package/Particles/particleSystem.d.ts +13 -1
- package/Particles/particleSystem.js +27 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Rendering/prePassRenderer.js +12 -2
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Rendering/subSurfaceConfiguration.js +1 -1
- package/Rendering/subSurfaceConfiguration.js.map +1 -1
- package/Rendering/utilityLayerRenderer.js +2 -0
- package/Rendering/utilityLayerRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/pointCloudVertex.js +1 -1
- package/Shaders/ShadersInclude/pointCloudVertex.js.map +1 -1
- package/Shaders/background.vertex.js +1 -1
- package/Shaders/background.vertex.js.map +1 -1
- package/Shaders/pbr.vertex.js +1 -1
- package/Shaders/pbr.vertex.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js +4 -2
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/webXRSessionManager.js +1 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +4 -4
- package/scene.d.ts +1 -10
- package/scene.js +20 -39
- package/scene.js.map +1 -1
- package/types.d.ts +1 -1
- package/types.js.map +1 -1
- package/Misc/baseError.d.ts +0 -7
- package/Misc/baseError.js +0 -18
- package/Misc/baseError.js.map +0 -1
|
@@ -158,7 +158,8 @@ export function CreatePolygon(name, options, scene, earcutInjection) {
|
|
|
158
158
|
}
|
|
159
159
|
polygonTriangulation.addHole(hole);
|
|
160
160
|
}
|
|
161
|
-
|
|
161
|
+
//updatability is set during applyToMesh; setting to true in triangulation build produces errors
|
|
162
|
+
var polygon = polygonTriangulation.build(false, depth, smoothingThreshold);
|
|
162
163
|
polygon._originalBuilderSideOrientation = options.sideOrientation;
|
|
163
164
|
var vertexData = CreatePolygonVertexData(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs, options.wrap);
|
|
164
165
|
vertexData.applyToMesh(polygon, options.updatable);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polygonBuilder.js","sourceRoot":"","sources":["../../../../sourceES6/core/Meshes/Builders/polygonBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAwB,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAIzE;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAa,EAAE,eAAuB,EAAE,GAAe,EAAE,OAAkB,EAAE,QAAkB,EAAE,OAAiB,EAAE,GAAa;IACrK,IAAI,MAAM,GAAc,GAAG,IAAI,IAAI,KAAK,CAAU,CAAC,CAAC,CAAC;IACrD,IAAI,UAAU,GAAG,OAAO,CAAC;IACzB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,OAAO,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;AACjE,CAAC,CAAC","sourcesContent":["import { Scene } from \"../../scene\";\r\nimport { Vector3, Vector2, Vector4 } from \"../../Maths/math.vector\";\r\nimport { Color4 } from '../../Maths/math.color';\r\nimport { Mesh, _CreationDataStorage } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { PolygonMeshBuilder } from \"../polygonMesh\";\r\nimport { FloatArray, IndicesArray, Nullable } from \"../../types\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { EngineStore } from '../../Engines/engineStore';\r\nimport { CompatibilityOptions } from \"../../Compat/compatibilityOptions\";\r\n\r\ndeclare var earcut: any;\r\n\r\n/**\r\n * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()\r\n * All parameters are provided by CreatePolygon as needed\r\n * @param polygon a mesh built from polygonTriangulation.build()\r\n * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively\r\n * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively\r\n * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)\r\n * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)\r\n * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side\r\n * @returns the VertexData of the Polygon\r\n */\r\nexport function CreatePolygonVertexData(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrp?: boolean) {\r\n var faceUV: Vector4[] = fUV || new Array<Vector4>(3);\r\n var faceColors = fColors;\r\n var colors = [];\r\n var wrap: boolean = wrp || false;\r\n\r\n // default face colors and UV if undefined\r\n for (var f = 0; f < 3; 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 var positions = <FloatArray>polygon.getVerticesData(VertexBuffer.PositionKind);\r\n var normals = <FloatArray>polygon.getVerticesData(VertexBuffer.NormalKind);\r\n var uvs = <FloatArray>polygon.getVerticesData(VertexBuffer.UVKind);\r\n var indices = <IndicesArray>polygon.getIndices();\r\n var startIndex = positions.length / 9;\r\n var disp = 0;\r\n var distX = 0;\r\n var distZ = 0;\r\n var dist = 0;\r\n var totalLen = 0;\r\n var cumulate = [0];\r\n if (wrap) {\r\n for (var idx = startIndex; idx < positions.length / 3; idx += 4) {\r\n distX = positions[3 * (idx + 2)] - positions[3 * idx];\r\n distZ = positions[3 * (idx + 2) + 2] - positions[3 * idx + 2];\r\n dist = Math.sqrt(distX * distX + distZ * distZ);\r\n totalLen += dist;\r\n cumulate.push(totalLen);\r\n }\r\n }\r\n // set face colours and textures\r\n var idx: number = 0;\r\n var face: number = 0;\r\n for (var index = 0; index < normals.length; index += 3) {\r\n //Edge Face no. 1\r\n if (Math.abs(normals[index + 1]) < 0.001) {\r\n face = 1;\r\n }\r\n //Top Face no. 0\r\n if (Math.abs(normals[index + 1] - 1) < 0.001) {\r\n face = 0;\r\n }\r\n //Bottom Face no. 2\r\n if (Math.abs(normals[index + 1] + 1) < 0.001) {\r\n face = 2;\r\n }\r\n idx = index / 3;\r\n if (face === 1) {\r\n disp = idx - startIndex;\r\n if (disp % 4 < 1.5) {\r\n if (wrap) {\r\n uvs[2 * idx] = faceUV[face].x + (faceUV[face].z - faceUV[face].x) * cumulate[Math.floor(disp / 4)] / totalLen;\r\n }\r\n else {\r\n uvs[2 * idx] = faceUV[face].x;\r\n }\r\n }\r\n else {\r\n if (wrap) {\r\n uvs[2 * idx] = faceUV[face].x + (faceUV[face].z - faceUV[face].x) * cumulate[Math.floor(disp / 4) + 1] / totalLen;\r\n }\r\n else {\r\n uvs[2 * idx] = faceUV[face].z;\r\n }\r\n }\r\n if (disp % 2 === 0) {\r\n uvs[2 * idx + 1] = CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[face].w : faceUV[face].w;\r\n }\r\n else {\r\n uvs[2 * idx + 1] = CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[face].y : faceUV[face].y;\r\n }\r\n }\r\n else {\r\n uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;\r\n uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;\r\n\r\n if (CompatibilityOptions.UseOpenGLOrientationForUV) {\r\n uvs[2 * idx + 1] = 1.0 - uvs[2 * idx + 1];\r\n }\r\n }\r\n if (faceColors) {\r\n colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);\r\n }\r\n }\r\n\r\n // sides\r\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);\r\n\r\n // Result\r\n var vertexData = new VertexData();\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 var 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 polygon mesh\r\n * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh\r\n * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors\r\n * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)\r\n * * Remember you can only change the shape positions, not their number when updating a polygon\r\n * @param name defines the name of the mesh\r\n * @param options defines the 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 the polygon mesh\r\n */\r\nexport function CreatePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, smoothingThreshold?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n var shape = options.shape;\r\n var holes = options.holes || [];\r\n var depth = options.depth || 0;\r\n var smoothingThreshold = options.smoothingThreshold || 2;\r\n var contours: Array<Vector2> = [];\r\n var hole: Array<Vector2> = [];\r\n\r\n for (var i = 0; i < shape.length; i++) {\r\n contours[i] = new Vector2(shape[i].x, shape[i].z);\r\n }\r\n var epsilon = 0.00000001;\r\n if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {\r\n contours.pop();\r\n }\r\n\r\n var polygonTriangulation = new PolygonMeshBuilder(name, contours, scene || EngineStore.LastCreatedScene!, earcutInjection);\r\n for (var hNb = 0; hNb < holes.length; hNb++) {\r\n hole = [];\r\n for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {\r\n hole.push(new Vector2(holes[hNb][hPoint].x, holes[hNb][hPoint].z));\r\n }\r\n polygonTriangulation.addHole(hole);\r\n }\r\n var polygon = polygonTriangulation.build(options.updatable, depth, smoothingThreshold);\r\n polygon._originalBuilderSideOrientation = options.sideOrientation;\r\n var vertexData = CreatePolygonVertexData(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs, options.wrap);\r\n vertexData.applyToMesh(polygon, options.updatable);\r\n\r\n return polygon;\r\n}\r\n\r\n/**\r\n * Creates an extruded polygon mesh, with depth in the Y direction.\r\n * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)\r\n * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors\r\n * @param name defines the name of the mesh\r\n * @param options defines the 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 the polygon mesh\r\n */\r\nexport function ExtrudePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {\r\n return CreatePolygon(name, options, scene, earcutInjection);\r\n}\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use the functions directly from the module\r\n */\r\nexport const PolygonBuilder = {\r\n ExtrudePolygon,\r\n CreatePolygon,\r\n};\r\n\r\nVertexData.CreatePolygon = CreatePolygonVertexData;\r\nMesh.CreatePolygon = (name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection = earcut): Mesh => {\r\n var options = {\r\n shape: shape,\r\n holes: holes,\r\n updatable: updatable,\r\n sideOrientation: sideOrientation\r\n };\r\n return CreatePolygon(name, options, scene, earcutInjection);\r\n};\r\n\r\nMesh.ExtrudePolygon = (name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection = earcut): Mesh => {\r\n var options = {\r\n shape: shape,\r\n holes: holes,\r\n depth: depth,\r\n updatable: updatable,\r\n sideOrientation: sideOrientation\r\n };\r\n return ExtrudePolygon(name, options, scene, earcutInjection);\r\n};"]}
|
|
1
|
+
{"version":3,"file":"polygonBuilder.js","sourceRoot":"","sources":["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AAC,aAAa,GAAG,uBAAuB,CAAC;AACnD,IAAI,CAAC,aAAa,GAAG,UAAC,IAAY,EAAE,KAAgB,EAAE,KAAY,EAAE,KAAmB,EAAE,SAAmB,EAAE,eAAwB,EAAE,eAAwB;IAAxB,gCAAA,EAAA,wBAAwB;IAC5J,IAAI,OAAO,GAAG;QACV,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,SAAS;QACpB,eAAe,EAAE,eAAe;KACnC,CAAC;IACF,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;AAChE,CAAC,CAAC;AAEF,IAAI,CAAC,cAAc,GAAG,UAAC,IAAY,EAAE,KAAgB,EAAE,KAAa,EAAE,KAAY,EAAE,KAAmB,EAAE,SAAmB,EAAE,eAAwB,EAAE,eAAwB;IAAxB,gCAAA,EAAA,wBAAwB;IAC5K,IAAI,OAAO,GAAG;QACV,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,KAAK;QACZ,KAAK,EAAE,KAAK;QACZ,SAAS,EAAE,SAAS;QACpB,eAAe,EAAE,eAAe;KACnC,CAAC;IACF,OAAO,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;AACjE,CAAC,CAAC","sourcesContent":["import { Scene } from \"../../scene\";\r\nimport { Vector3, Vector2, Vector4 } from \"../../Maths/math.vector\";\r\nimport { Color4 } from '../../Maths/math.color';\r\nimport { Mesh, _CreationDataStorage } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { PolygonMeshBuilder } from \"../polygonMesh\";\r\nimport { FloatArray, IndicesArray, Nullable } from \"../../types\";\r\nimport { VertexBuffer } from \"../../Buffers/buffer\";\r\nimport { EngineStore } from '../../Engines/engineStore';\r\nimport { CompatibilityOptions } from \"../../Compat/compatibilityOptions\";\r\n\r\ndeclare var earcut: any;\r\n\r\n/**\r\n * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()\r\n * All parameters are provided by CreatePolygon as needed\r\n * @param polygon a mesh built from polygonTriangulation.build()\r\n * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively\r\n * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively\r\n * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)\r\n * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)\r\n * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side\r\n * @returns the VertexData of the Polygon\r\n */\r\nexport function CreatePolygonVertexData(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrp?: boolean) {\r\n var faceUV: Vector4[] = fUV || new Array<Vector4>(3);\r\n var faceColors = fColors;\r\n var colors = [];\r\n var wrap: boolean = wrp || false;\r\n\r\n // default face colors and UV if undefined\r\n for (var f = 0; f < 3; 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 var positions = <FloatArray>polygon.getVerticesData(VertexBuffer.PositionKind);\r\n var normals = <FloatArray>polygon.getVerticesData(VertexBuffer.NormalKind);\r\n var uvs = <FloatArray>polygon.getVerticesData(VertexBuffer.UVKind);\r\n var indices = <IndicesArray>polygon.getIndices();\r\n var startIndex = positions.length / 9;\r\n var disp = 0;\r\n var distX = 0;\r\n var distZ = 0;\r\n var dist = 0;\r\n var totalLen = 0;\r\n var cumulate = [0];\r\n if (wrap) {\r\n for (var idx = startIndex; idx < positions.length / 3; idx += 4) {\r\n distX = positions[3 * (idx + 2)] - positions[3 * idx];\r\n distZ = positions[3 * (idx + 2) + 2] - positions[3 * idx + 2];\r\n dist = Math.sqrt(distX * distX + distZ * distZ);\r\n totalLen += dist;\r\n cumulate.push(totalLen);\r\n }\r\n }\r\n // set face colours and textures\r\n var idx: number = 0;\r\n var face: number = 0;\r\n for (var index = 0; index < normals.length; index += 3) {\r\n //Edge Face no. 1\r\n if (Math.abs(normals[index + 1]) < 0.001) {\r\n face = 1;\r\n }\r\n //Top Face no. 0\r\n if (Math.abs(normals[index + 1] - 1) < 0.001) {\r\n face = 0;\r\n }\r\n //Bottom Face no. 2\r\n if (Math.abs(normals[index + 1] + 1) < 0.001) {\r\n face = 2;\r\n }\r\n idx = index / 3;\r\n if (face === 1) {\r\n disp = idx - startIndex;\r\n if (disp % 4 < 1.5) {\r\n if (wrap) {\r\n uvs[2 * idx] = faceUV[face].x + (faceUV[face].z - faceUV[face].x) * cumulate[Math.floor(disp / 4)] / totalLen;\r\n }\r\n else {\r\n uvs[2 * idx] = faceUV[face].x;\r\n }\r\n }\r\n else {\r\n if (wrap) {\r\n uvs[2 * idx] = faceUV[face].x + (faceUV[face].z - faceUV[face].x) * cumulate[Math.floor(disp / 4) + 1] / totalLen;\r\n }\r\n else {\r\n uvs[2 * idx] = faceUV[face].z;\r\n }\r\n }\r\n if (disp % 2 === 0) {\r\n uvs[2 * idx + 1] = CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[face].w : faceUV[face].w;\r\n }\r\n else {\r\n uvs[2 * idx + 1] = CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[face].y : faceUV[face].y;\r\n }\r\n }\r\n else {\r\n uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;\r\n uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;\r\n\r\n if (CompatibilityOptions.UseOpenGLOrientationForUV) {\r\n uvs[2 * idx + 1] = 1.0 - uvs[2 * idx + 1];\r\n }\r\n }\r\n if (faceColors) {\r\n colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);\r\n }\r\n }\r\n\r\n // sides\r\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);\r\n\r\n // Result\r\n var vertexData = new VertexData();\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 var 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 polygon mesh\r\n * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh\r\n * * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors\r\n * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)\r\n * * Remember you can only change the shape positions, not their number when updating a polygon\r\n * @param name defines the name of the mesh\r\n * @param options defines the 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 the polygon mesh\r\n */\r\nexport function CreatePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, smoothingThreshold?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n var shape = options.shape;\r\n var holes = options.holes || [];\r\n var depth = options.depth || 0;\r\n var smoothingThreshold = options.smoothingThreshold || 2;\r\n var contours: Array<Vector2> = [];\r\n var hole: Array<Vector2> = [];\r\n\r\n for (var i = 0; i < shape.length; i++) {\r\n contours[i] = new Vector2(shape[i].x, shape[i].z);\r\n }\r\n var epsilon = 0.00000001;\r\n if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {\r\n contours.pop();\r\n }\r\n\r\n var polygonTriangulation = new PolygonMeshBuilder(name, contours, scene || EngineStore.LastCreatedScene!, earcutInjection);\r\n for (var hNb = 0; hNb < holes.length; hNb++) {\r\n hole = [];\r\n for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {\r\n hole.push(new Vector2(holes[hNb][hPoint].x, holes[hNb][hPoint].z));\r\n }\r\n polygonTriangulation.addHole(hole);\r\n }\r\n //updatability is set during applyToMesh; setting to true in triangulation build produces errors\r\n var polygon = polygonTriangulation.build(false, depth, smoothingThreshold);\r\n polygon._originalBuilderSideOrientation = options.sideOrientation;\r\n var vertexData = CreatePolygonVertexData(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs, options.wrap);\r\n vertexData.applyToMesh(polygon, options.updatable);\r\n\r\n return polygon;\r\n}\r\n\r\n/**\r\n * Creates an extruded polygon mesh, with depth in the Y direction.\r\n * * You can set different colors and different images to the top, bottom and extruded side by using the parameters `faceColors` (an array of 3 Color3 elements) and `faceUV` (an array of 3 Vector4 elements)\r\n * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors\r\n * @param name defines the name of the mesh\r\n * @param options defines the 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 the polygon mesh\r\n */\r\nexport function ExtrudePolygon(name: string, options: { shape: Vector3[], holes?: Vector3[][], depth?: number, faceUV?: Vector4[], faceColors?: Color4[], updatable?: boolean, sideOrientation?: number, frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean }, scene: Nullable<Scene> = null, earcutInjection = earcut): Mesh {\r\n return CreatePolygon(name, options, scene, earcutInjection);\r\n}\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated use the functions directly from the module\r\n */\r\nexport const PolygonBuilder = {\r\n ExtrudePolygon,\r\n CreatePolygon,\r\n};\r\n\r\nVertexData.CreatePolygon = CreatePolygonVertexData;\r\nMesh.CreatePolygon = (name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection = earcut): Mesh => {\r\n var options = {\r\n shape: shape,\r\n holes: holes,\r\n updatable: updatable,\r\n sideOrientation: sideOrientation\r\n };\r\n return CreatePolygon(name, options, scene, earcutInjection);\r\n};\r\n\r\nMesh.ExtrudePolygon = (name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection = earcut): Mesh => {\r\n var options = {\r\n shape: shape,\r\n holes: holes,\r\n depth: depth,\r\n updatable: updatable,\r\n sideOrientation: sideOrientation\r\n };\r\n return ExtrudePolygon(name, options, scene, earcutInjection);\r\n};"]}
|
package/Meshes/abstractMesh.d.ts
CHANGED
|
@@ -234,7 +234,7 @@ export declare class AbstractMesh extends TransformNode implements IDisposable,
|
|
|
234
234
|
*/
|
|
235
235
|
onCollideObservable: Observable<AbstractMesh>;
|
|
236
236
|
/** Set a function to call when this mesh collides with another one */
|
|
237
|
-
set onCollide(callback: () => void);
|
|
237
|
+
set onCollide(callback: (collidedMesh?: AbstractMesh) => void);
|
|
238
238
|
/**
|
|
239
239
|
* An event triggered when the collision's position changes
|
|
240
240
|
*/
|