@babylonjs/core 8.52.0 → 8.52.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/Animations/animatorAvatar.d.ts +31 -16
- package/Animations/animatorAvatar.js +138 -86
- package/Animations/animatorAvatar.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.d.ts +6 -0
- package/Behaviors/Meshes/pointerDragBehavior.js +4 -0
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Gizmos/axisDragGizmo.d.ts +1 -1
- package/Gizmos/axisDragGizmo.js +13 -5
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/gizmo.js +8 -2
- package/Gizmos/gizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.js +10 -3
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js +10 -0
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js +10 -4
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Materials/effect.functions.js +29 -21
- package/Materials/effect.functions.js.map +1 -1
- package/Meshes/thinInstanceMesh.d.ts +7 -3
- package/Meshes/thinInstanceMesh.js +15 -3
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.js +3 -3
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +2 -2
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/depthPrePass.js +4 -1
- package/ShadersWGSL/ShadersInclude/depthPrePass.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +1 -1
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
- package/package.json +1 -1
|
@@ -122,6 +122,10 @@ export class PlaneRotationGizmo extends Gizmo {
|
|
|
122
122
|
let localPlaneNormalTowardsCamera = new Vector3();
|
|
123
123
|
this.dragBehavior.onDragStartObservable.add((e) => {
|
|
124
124
|
if (this.attachedNode) {
|
|
125
|
+
if (this._additionalTransformNode) {
|
|
126
|
+
this._additionalTransformNode.getWorldMatrix().invertToRef(TmpVectors.Matrix[0]);
|
|
127
|
+
Vector3.TransformCoordinatesToRef(e.dragPlanePoint, TmpVectors.Matrix[0], e.dragPlanePoint);
|
|
128
|
+
}
|
|
125
129
|
lastDragPosition.copyFrom(e.dragPlanePoint);
|
|
126
130
|
this._rotationDisplayPlane.setEnabled(true);
|
|
127
131
|
this._rotationDisplayPlane.getWorldMatrix().invertToRef(rotationMatrix);
|
|
@@ -133,6 +137,8 @@ export class PlaneRotationGizmo extends Gizmo {
|
|
|
133
137
|
lastDragPosition.copyFrom(e.dragPlanePoint);
|
|
134
138
|
this._rotationShaderMaterial.setVector3("angles", this._angles);
|
|
135
139
|
this.angle = 0;
|
|
140
|
+
// there is an issue with the rotation plane with additionalTransformNode, so we hide it in that case to avoid confusion
|
|
141
|
+
this._rotationDisplayPlane.visibility = this._additionalTransformNode ? 0 : 0.999;
|
|
136
142
|
}
|
|
137
143
|
});
|
|
138
144
|
this.dragBehavior.onDragEndObservable.add(() => {
|
|
@@ -169,6 +175,10 @@ export class PlaneRotationGizmo extends Gizmo {
|
|
|
169
175
|
}
|
|
170
176
|
nodeQuaternion.normalize();
|
|
171
177
|
const nodeTranslationForOperation = this.updateGizmoPositionToMatchAttachedMesh ? nodeTranslation : this._rootMesh.absolutePosition;
|
|
178
|
+
if (this._additionalTransformNode) {
|
|
179
|
+
this._additionalTransformNode.getWorldMatrix().invertToRef(TmpVectors.Matrix[0]);
|
|
180
|
+
Vector3.TransformCoordinatesToRef(event.dragPlanePoint, TmpVectors.Matrix[0], event.dragPlanePoint);
|
|
181
|
+
}
|
|
172
182
|
const newVector = event.dragPlanePoint.subtract(nodeTranslationForOperation).normalize();
|
|
173
183
|
const originalVector = lastDragPosition.subtract(nodeTranslationForOperation).normalize();
|
|
174
184
|
const cross = Vector3.Cross(newVector, originalVector);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planeRotationGizmo.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/planeRotationGizmo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAiCxC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAiCzC,4EAA4E;I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,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;QACzC,CAAC;QACD,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC/B,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,CAAC;QAC3C,CAAC;QACD,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACtF,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC3B,IAAI,IAAI,EAAE,CAAC;gBACP,IAAI,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;QACL,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;;AApcD;;;GAGG;AACW,+BAAY,GAAW,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,AAA7B,CAA8B;AA0CvC,6CAA0B,GAAG;;;;;;;;;;;UAWxC,AAXqC,CAWpC;AAEU,+CAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+B/C,AA/B4C,CA+B3C","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport { Quaternion, Matrix, Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport \"../Meshes/Builders/linesBuilder\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Node } from \"../node\";\r\nimport { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { GizmoAxisCache, IGizmo } from \"./gizmo\";\r\nimport { Gizmo } from \"./gizmo\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { RotationGizmo } from \"./rotationGizmo\";\r\nimport { ShaderMaterial } from \"../Materials/shaderMaterial\";\r\nimport { Effect } from \"../Materials/effect\";\r\nimport { CreatePlane } from \"../Meshes/Builders/planeBuilder\";\r\nimport { CreateTorus } from \"../Meshes/Builders/torusBuilder\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\n\r\n/**\r\n * Interface for plane rotation gizmo\r\n */\r\nexport interface IPlaneRotationGizmo extends IGizmo {\r\n /** Drag behavior responsible for the gizmos dragging interactions */\r\n dragBehavior: PointerDragBehavior;\r\n /** Drag distance in babylon units that the gizmo will snap to when dragged */\r\n snapDistance: number;\r\n /** Sensitivity factor for dragging */\r\n sensitivity: number;\r\n /**\r\n * Event that fires each time the gizmo snaps to a new location.\r\n * * snapDistance is the change in distance\r\n */\r\n onSnapObservable: Observable<{ snapDistance: number }>;\r\n /** Accumulated relative angle value for rotation on the axis. */\r\n angle: number;\r\n /** If the gizmo is enabled */\r\n isEnabled: boolean;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n coloredMaterial: StandardMaterial;\r\n /** Material used to render when gizmo is hovered with mouse */\r\n hoverMaterial: StandardMaterial;\r\n /** Color used to render the drag angle sector when gizmo is rotated with mouse */\r\n rotationColor: Color3;\r\n /** Material used to render when gizmo is disabled. typically grey. */\r\n disableMaterial: StandardMaterial;\r\n}\r\n\r\n/**\r\n * Single plane rotation gizmo\r\n */\r\nexport class PlaneRotationGizmo extends Gizmo implements IPlaneRotationGizmo {\r\n /**\r\n * Drag behavior responsible for the gizmos dragging interactions\r\n */\r\n public dragBehavior: PointerDragBehavior;\r\n protected _pointerObserver: Nullable<Observer<PointerInfo>> = null;\r\n\r\n /**\r\n * Rotation distance in radians that the gizmo will snap to (Default: 0)\r\n */\r\n public snapDistance = 0;\r\n /**\r\n * Event that fires each time the gizmo snaps to a new location.\r\n * * snapDistance is the change in distance\r\n */\r\n public onSnapObservable = new Observable<{ snapDistance: number }>();\r\n\r\n /**\r\n * The maximum angle between the camera and the rotation allowed for interaction\r\n * If a rotation plane appears 'flat', a lower value allows interaction.\r\n */\r\n public static MaxDragAngle: number = (Math.PI * 9) / 20;\r\n\r\n /**\r\n * Accumulated relative angle value for rotation on the axis. Reset to 0 when a dragStart occurs\r\n */\r\n public angle: number = 0;\r\n\r\n /**\r\n * Custom sensitivity value for the drag strength\r\n */\r\n public sensitivity = 1;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n public get coloredMaterial() {\r\n return this._coloredMaterial;\r\n }\r\n\r\n /** Material used to render when gizmo is hovered with mouse */\r\n public get hoverMaterial() {\r\n return this._hoverMaterial;\r\n }\r\n\r\n /** Color used to render the drag angle sector when gizmo is rotated with mouse */\r\n public set rotationColor(color: Color3) {\r\n this._rotationShaderMaterial.setColor3(\"rotationColor\", color);\r\n }\r\n\r\n /** Material used to render when gizmo is disabled. typically grey. */\r\n public get disableMaterial() {\r\n return this._disableMaterial;\r\n }\r\n\r\n protected _isEnabled: boolean = true;\r\n protected _parent: Nullable<RotationGizmo> = null;\r\n protected _coloredMaterial: StandardMaterial;\r\n protected _hoverMaterial: StandardMaterial;\r\n protected _disableMaterial: StandardMaterial;\r\n protected _gizmoMesh: Mesh;\r\n protected _rotationDisplayPlane: Mesh;\r\n protected _dragging: boolean = false;\r\n protected _angles = new Vector3();\r\n\r\n protected static _RotationGizmoVertexShader = `\r\n precision highp float;\r\n attribute vec3 position;\r\n attribute vec2 uv;\r\n uniform mat4 worldViewProjection;\r\n varying vec3 vPosition;\r\n varying vec2 vUV;\r\n\r\n void main(void) {\r\n gl_Position = worldViewProjection * vec4(position, 1.0);\r\n vUV = uv;\r\n }`;\r\n\r\n protected static _RotationGizmoFragmentShader = `\r\n precision highp float;\r\n varying vec2 vUV;\r\n varying vec3 vPosition;\r\n uniform vec3 angles;\r\n uniform vec3 rotationColor;\r\n\r\n #define twopi 6.283185307\r\n\r\n void main(void) {\r\n vec2 uv = vUV - vec2(0.5);\r\n float angle = atan(uv.y, uv.x) + 3.141592;\r\n float delta = gl_FrontFacing ? angles.y : -angles.y;\r\n float begin = angles.x - delta * angles.z;\r\n float start = (begin < (begin + delta)) ? begin : (begin + delta);\r\n float end = (begin > (begin + delta)) ? begin : (begin + delta);\r\n float len = sqrt(dot(uv,uv));\r\n float opacity = 1. - step(0.5, len);\r\n\r\n float base = abs(floor(start / twopi)) * twopi;\r\n start += base;\r\n end += base;\r\n\r\n float intensity = 0.;\r\n for (int i = 0; i < 5; i++)\r\n {\r\n intensity += max(step(start, angle) - step(end, angle), 0.);\r\n angle += twopi;\r\n }\r\n gl_FragColor = vec4(rotationColor, min(intensity * 0.25, 0.8)) * opacity;\r\n }\r\n `;\r\n\r\n protected _rotationShaderMaterial: ShaderMaterial;\r\n\r\n /**\r\n * Creates a PlaneRotationGizmo\r\n * @param planeNormal The normal of the plane which the gizmo will be able to rotate on\r\n * @param color The color of the gizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n * @param tessellation Amount of tessellation to be used when creating rotation circles\r\n * @param parent\r\n * @param useEulerRotation Use and update Euler angle instead of quaternion\r\n * @param thickness display gizmo axis thickness\r\n * @param hoverColor The color of the gizmo when hovering over and dragging\r\n * @param disableColor The Color of the gizmo when its disabled\r\n */\r\n constructor(\r\n planeNormal: Vector3,\r\n color: Color3 = Color3.Gray(),\r\n gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer,\r\n tessellation = 32,\r\n parent: Nullable<RotationGizmo> = null,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n useEulerRotation = false,\r\n thickness: number = 1,\r\n hoverColor: Color3 = Color3.Yellow(),\r\n disableColor: Color3 = Color3.Gray()\r\n ) {\r\n super(gizmoLayer);\r\n this._parent = parent;\r\n // Create Material\r\n this._coloredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._coloredMaterial.diffuseColor = color;\r\n this._coloredMaterial.specularColor = color.subtract(new Color3(0.1, 0.1, 0.1));\r\n\r\n this._hoverMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._hoverMaterial.diffuseColor = hoverColor;\r\n this._hoverMaterial.specularColor = hoverColor;\r\n\r\n this._disableMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._disableMaterial.diffuseColor = disableColor;\r\n this._disableMaterial.alpha = 0.4;\r\n\r\n // Build mesh on root node\r\n this._gizmoMesh = new Mesh(\"\", gizmoLayer.utilityLayerScene);\r\n const { rotationMesh, collider } = this._createGizmoMesh(this._gizmoMesh, thickness, tessellation);\r\n\r\n // Setup Rotation Circle\r\n this._rotationDisplayPlane = CreatePlane(\r\n \"rotationDisplay\",\r\n {\r\n size: 0.6,\r\n updatable: false,\r\n },\r\n this.gizmoLayer.utilityLayerScene\r\n );\r\n this._rotationDisplayPlane.rotation.z = Math.PI * 0.5;\r\n this._rotationDisplayPlane.parent = this._gizmoMesh;\r\n this._rotationDisplayPlane.setEnabled(false);\r\n\r\n Effect.ShadersStore[\"rotationGizmoVertexShader\"] = PlaneRotationGizmo._RotationGizmoVertexShader;\r\n Effect.ShadersStore[\"rotationGizmoFragmentShader\"] = PlaneRotationGizmo._RotationGizmoFragmentShader;\r\n this._rotationShaderMaterial = new ShaderMaterial(\r\n \"shader\",\r\n this.gizmoLayer.utilityLayerScene,\r\n {\r\n vertex: \"rotationGizmo\",\r\n fragment: \"rotationGizmo\",\r\n },\r\n {\r\n attributes: [\"position\", \"uv\"],\r\n uniforms: [\"worldViewProjection\", \"angles\", \"rotationColor\"],\r\n }\r\n );\r\n this._rotationShaderMaterial.backFaceCulling = false;\r\n this.rotationColor = hoverColor;\r\n\r\n this._rotationDisplayPlane.material = this._rotationShaderMaterial;\r\n this._rotationDisplayPlane.visibility = 0.999;\r\n\r\n this._gizmoMesh.lookAt(this._rootMesh.position.add(planeNormal));\r\n this._rootMesh.addChild(this._gizmoMesh, Gizmo.PreserveScaling);\r\n this._gizmoMesh.scaling.scaleInPlace(1 / 3);\r\n // Add drag behavior to handle events when the gizmo is dragged\r\n this.dragBehavior = new PointerDragBehavior({ dragPlaneNormal: planeNormal });\r\n this.dragBehavior.moveAttached = false;\r\n this.dragBehavior.maxDragAngle = PlaneRotationGizmo.MaxDragAngle;\r\n this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;\r\n this._rootMesh.addBehavior(this.dragBehavior);\r\n\r\n // Closures for drag logic\r\n const lastDragPosition = new Vector3();\r\n\r\n const rotationMatrix = new Matrix();\r\n const planeNormalTowardsCamera = new Vector3();\r\n let localPlaneNormalTowardsCamera = new Vector3();\r\n\r\n this.dragBehavior.onDragStartObservable.add((e) => {\r\n if (this.attachedNode) {\r\n lastDragPosition.copyFrom(e.dragPlanePoint);\r\n this._rotationDisplayPlane.setEnabled(true);\r\n\r\n this._rotationDisplayPlane.getWorldMatrix().invertToRef(rotationMatrix);\r\n Vector3.TransformCoordinatesToRef(e.dragPlanePoint, rotationMatrix, lastDragPosition);\r\n\r\n this._angles.x = Math.atan2(lastDragPosition.y, lastDragPosition.x) + Math.PI;\r\n this._angles.y = 0;\r\n this._angles.z = this.updateGizmoRotationToMatchAttachedMesh ? 1 : 0;\r\n this._dragging = true;\r\n lastDragPosition.copyFrom(e.dragPlanePoint);\r\n this._rotationShaderMaterial.setVector3(\"angles\", this._angles);\r\n this.angle = 0;\r\n }\r\n });\r\n\r\n this.dragBehavior.onDragEndObservable.add(() => {\r\n this._dragging = false;\r\n this._rotationDisplayPlane.setEnabled(false);\r\n });\r\n\r\n const tmpSnapEvent = { snapDistance: 0 };\r\n let currentSnapDragDistance = 0;\r\n const tmpMatrix = new Matrix();\r\n const amountToRotate = new Quaternion();\r\n this.dragBehavior.onDragObservable.add((event) => {\r\n if (this.attachedNode) {\r\n // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)\r\n const nodeScale = new Vector3(1, 1, 1);\r\n const nodeQuaternion = new Quaternion(0, 0, 0, 1);\r\n const nodeTranslation = new Vector3(0, 0, 0);\r\n const attachedNodeTransform = this._attachedNode as TransformNode;\r\n // check there is an active pivot for the TransformNode attached\r\n if (attachedNodeTransform && attachedNodeTransform.isUsingPivotMatrix && attachedNodeTransform.isUsingPivotMatrix() && attachedNodeTransform.position) {\r\n // When a TransformNode has an active pivot, even without parenting,\r\n // translation from the world matrix is different from TransformNode.position.\r\n // Pivot works like a virtual parent that's using the node orientation.\r\n // As the world matrix is transformed by the gizmo and then decomposed to TRS\r\n // its translation part must be set to the Node's position.\r\n attachedNodeTransform.getWorldMatrix().setTranslation(attachedNodeTransform.position);\r\n }\r\n\r\n this.attachedNode.getWorldMatrix().decompose(nodeScale, nodeQuaternion, nodeTranslation);\r\n // uniform scaling of absolute value of components\r\n // (-1,1,1) is uniform but (1,1.001,1) is not\r\n const uniformScaling = Math.abs(Math.abs(nodeScale.x) - Math.abs(nodeScale.y)) <= Epsilon && Math.abs(Math.abs(nodeScale.x) - Math.abs(nodeScale.z)) <= Epsilon;\r\n if (!uniformScaling && this.updateGizmoRotationToMatchAttachedMesh) {\r\n Logger.Warn(\r\n \"Unable to use a rotation gizmo matching mesh rotation with non uniform scaling. Use uniform scaling or set updateGizmoRotationToMatchAttachedMesh to false.\"\r\n );\r\n return;\r\n }\r\n nodeQuaternion.normalize();\r\n\r\n const nodeTranslationForOperation = this.updateGizmoPositionToMatchAttachedMesh ? nodeTranslation : this._rootMesh.absolutePosition;\r\n const newVector = event.dragPlanePoint.subtract(nodeTranslationForOperation).normalize();\r\n const originalVector = lastDragPosition.subtract(nodeTranslationForOperation).normalize();\r\n const cross = Vector3.Cross(newVector, originalVector);\r\n const dot = Vector3.Dot(newVector, originalVector);\r\n let angle = Math.atan2(cross.length(), dot) * this.sensitivity;\r\n planeNormalTowardsCamera.copyFrom(planeNormal);\r\n localPlaneNormalTowardsCamera.copyFrom(planeNormal);\r\n if (this.updateGizmoRotationToMatchAttachedMesh) {\r\n nodeQuaternion.toRotationMatrix(rotationMatrix);\r\n localPlaneNormalTowardsCamera = Vector3.TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);\r\n }\r\n // Flip up vector depending on which side the camera is on\r\n let cameraFlipped = false;\r\n if (gizmoLayer.utilityLayerScene.activeCamera) {\r\n const camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(nodeTranslationForOperation).normalize();\r\n if (Vector3.Dot(camVec, localPlaneNormalTowardsCamera) > 0) {\r\n planeNormalTowardsCamera.scaleInPlace(-1);\r\n localPlaneNormalTowardsCamera.scaleInPlace(-1);\r\n cameraFlipped = true;\r\n }\r\n }\r\n const halfCircleSide = Vector3.Dot(localPlaneNormalTowardsCamera, cross) > 0.0;\r\n if (halfCircleSide) {\r\n angle = -angle;\r\n }\r\n\r\n TmpVectors.Vector3[0].set(angle, 0, 0);\r\n if (!this.dragBehavior.validateDrag(TmpVectors.Vector3[0])) {\r\n angle = 0;\r\n }\r\n\r\n // Snapping logic\r\n let snapped = false;\r\n if (this.snapDistance != 0) {\r\n currentSnapDragDistance += angle;\r\n if (Math.abs(currentSnapDragDistance) > this.snapDistance) {\r\n let dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / this.snapDistance);\r\n if (currentSnapDragDistance < 0) {\r\n dragSteps *= -1;\r\n }\r\n currentSnapDragDistance = currentSnapDragDistance % this.snapDistance;\r\n angle = this.snapDistance * dragSteps;\r\n snapped = true;\r\n } else {\r\n angle = 0;\r\n }\r\n }\r\n\r\n // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)\r\n const quaternionCoefficient = Math.sin(angle / 2);\r\n amountToRotate.set(\r\n planeNormalTowardsCamera.x * quaternionCoefficient,\r\n planeNormalTowardsCamera.y * quaternionCoefficient,\r\n planeNormalTowardsCamera.z * quaternionCoefficient,\r\n Math.cos(angle / 2)\r\n );\r\n\r\n // If the meshes local scale is inverted (eg. loaded gltf file parent with z scale of -1) the rotation needs to be inverted on the y axis\r\n if (tmpMatrix.determinant() > 0) {\r\n const tmpVector = new Vector3();\r\n amountToRotate.toEulerAnglesToRef(tmpVector);\r\n Quaternion.RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);\r\n }\r\n\r\n if (this.updateGizmoRotationToMatchAttachedMesh) {\r\n // Rotate selected mesh quaternion over fixed axis\r\n nodeQuaternion.multiplyToRef(amountToRotate, nodeQuaternion);\r\n nodeQuaternion.normalize();\r\n // recompose matrix\r\n Matrix.ComposeToRef(nodeScale, nodeQuaternion, nodeTranslation, this.attachedNode.getWorldMatrix());\r\n } else {\r\n // Rotate selected mesh quaternion over rotated axis\r\n amountToRotate.toRotationMatrix(TmpVectors.Matrix[0]);\r\n const translation = this.attachedNode.getWorldMatrix().getTranslation();\r\n this.attachedNode.getWorldMatrix().multiplyToRef(TmpVectors.Matrix[0], this.attachedNode.getWorldMatrix());\r\n this.attachedNode.getWorldMatrix().setTranslation(translation);\r\n }\r\n\r\n lastDragPosition.copyFrom(event.dragPlanePoint);\r\n if (snapped) {\r\n tmpSnapEvent.snapDistance = angle;\r\n this.onSnapObservable.notifyObservers(tmpSnapEvent);\r\n }\r\n this._angles.y += gizmoLayer.utilityLayerScene.useRightHandedSystem ? -angle : angle;\r\n this.angle += cameraFlipped ? -angle : angle;\r\n this._rotationShaderMaterial.setVector3(\"angles\", this._angles);\r\n this._matrixChanged();\r\n }\r\n });\r\n\r\n const light = gizmoLayer._getSharedGizmoLight();\r\n light.includedOnlyMeshes = light.includedOnlyMeshes.concat(this._rootMesh.getChildMeshes(false));\r\n\r\n const cache: GizmoAxisCache = {\r\n colliderMeshes: [collider],\r\n gizmoMeshes: [rotationMesh],\r\n material: this._coloredMaterial,\r\n hoverMaterial: this._hoverMaterial,\r\n disableMaterial: this._disableMaterial,\r\n active: false,\r\n dragBehavior: this.dragBehavior,\r\n };\r\n this._parent?.addToAxisCache(this._gizmoMesh, cache);\r\n\r\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (this._customMeshSet) {\r\n return;\r\n }\r\n // updating here the maxangle because ondragstart is too late (value already used) and the updated value is not taken into account\r\n this.dragBehavior.maxDragAngle = PlaneRotationGizmo.MaxDragAngle;\r\n this._isHovered = !!(cache.colliderMeshes.indexOf(<Mesh>pointerInfo?.pickInfo?.pickedMesh) != -1);\r\n if (!this._parent) {\r\n const material = cache.dragBehavior.enabled ? (this._isHovered || this._dragging ? this._hoverMaterial : this._coloredMaterial) : this._disableMaterial;\r\n this._setGizmoMeshMaterial(cache.gizmoMeshes, material);\r\n }\r\n });\r\n\r\n this.dragBehavior.onEnabledObservable.add((newState) => {\r\n this._setGizmoMeshMaterial(cache.gizmoMeshes, newState ? this._coloredMaterial : this._disableMaterial);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n * Create Geometry for Gizmo\r\n * @param parentMesh\r\n * @param thickness\r\n * @param tessellation\r\n * @returns\r\n */\r\n protected _createGizmoMesh(parentMesh: AbstractMesh, thickness: number, tessellation: number) {\r\n const collider = CreateTorus(\r\n \"ignore\",\r\n {\r\n diameter: 0.6,\r\n thickness: 0.03 * thickness,\r\n tessellation,\r\n },\r\n this.gizmoLayer.utilityLayerScene\r\n );\r\n collider.visibility = 0;\r\n const rotationMesh = CreateTorus(\r\n \"\",\r\n {\r\n diameter: 0.6,\r\n thickness: 0.005 * thickness,\r\n tessellation,\r\n },\r\n this.gizmoLayer.utilityLayerScene\r\n );\r\n rotationMesh.material = this._coloredMaterial;\r\n\r\n // Position arrow pointing in its drag axis\r\n rotationMesh.rotation.x = Math.PI / 2;\r\n collider.rotation.x = Math.PI / 2;\r\n\r\n parentMesh.addChild(rotationMesh, Gizmo.PreserveScaling);\r\n parentMesh.addChild(collider, Gizmo.PreserveScaling);\r\n return { rotationMesh, collider };\r\n }\r\n\r\n protected override _attachedNodeChanged(value: Nullable<Node>) {\r\n if (this.dragBehavior) {\r\n this.dragBehavior.enabled = value ? true : false;\r\n }\r\n }\r\n\r\n /**\r\n * If the gizmo is enabled\r\n */\r\n public set isEnabled(value: boolean) {\r\n this._isEnabled = value;\r\n if (!value) {\r\n this.attachedMesh = null;\r\n } else {\r\n if (this._parent) {\r\n this.attachedMesh = this._parent.attachedMesh;\r\n }\r\n }\r\n }\r\n\r\n public get isEnabled(): boolean {\r\n return this._isEnabled;\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo\r\n */\r\n public override dispose() {\r\n this.onSnapObservable.clear();\r\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\r\n this.dragBehavior.detach();\r\n if (this._gizmoMesh) {\r\n this._gizmoMesh.dispose();\r\n }\r\n if (this._rotationDisplayPlane) {\r\n this._rotationDisplayPlane.dispose();\r\n }\r\n if (this._rotationShaderMaterial) {\r\n this._rotationShaderMaterial.dispose();\r\n }\r\n const materials = [this._coloredMaterial, this._hoverMaterial, this._disableMaterial];\r\n for (const matl of materials) {\r\n if (matl) {\r\n matl.dispose();\r\n }\r\n }\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"planeRotationGizmo.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/planeRotationGizmo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGhD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,C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AAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACpF,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAC7B,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;QACzC,CAAC;QACD,IAAI,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC/B,IAAI,CAAC,uBAAuB,CAAC,OAAO,EAAE,CAAC;QAC3C,CAAC;QACD,MAAM,SAAS,GAAG,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACtF,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC3B,IAAI,IAAI,EAAE,CAAC;gBACP,IAAI,CAAC,OAAO,EAAE,CAAC;YACnB,CAAC;QACL,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;;AA9cD;;;GAGG;AACW,+BAAY,GAAW,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,AAA7B,CAA8B;AA0CvC,6CAA0B,GAAG;;;;;;;;;;;UAWxC,AAXqC,CAWpC;AAEU,+CAA4B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+B/C,AA/B4C,CA+B3C","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport { Quaternion, Matrix, Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport \"../Meshes/Builders/linesBuilder\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Node } from \"../node\";\r\nimport { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { GizmoAxisCache, IGizmo } from \"./gizmo\";\r\nimport { Gizmo } from \"./gizmo\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { RotationGizmo } from \"./rotationGizmo\";\r\nimport { ShaderMaterial } from \"../Materials/shaderMaterial\";\r\nimport { Effect } from \"../Materials/effect\";\r\nimport { CreatePlane } from \"../Meshes/Builders/planeBuilder\";\r\nimport { CreateTorus } from \"../Meshes/Builders/torusBuilder\";\r\nimport { Epsilon } from \"../Maths/math.constants\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport type { TransformNode } from \"../Meshes/transformNode\";\r\n\r\n/**\r\n * Interface for plane rotation gizmo\r\n */\r\nexport interface IPlaneRotationGizmo extends IGizmo {\r\n /** Drag behavior responsible for the gizmos dragging interactions */\r\n dragBehavior: PointerDragBehavior;\r\n /** Drag distance in babylon units that the gizmo will snap to when dragged */\r\n snapDistance: number;\r\n /** Sensitivity factor for dragging */\r\n sensitivity: number;\r\n /**\r\n * Event that fires each time the gizmo snaps to a new location.\r\n * * snapDistance is the change in distance\r\n */\r\n onSnapObservable: Observable<{ snapDistance: number }>;\r\n /** Accumulated relative angle value for rotation on the axis. */\r\n angle: number;\r\n /** If the gizmo is enabled */\r\n isEnabled: boolean;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n coloredMaterial: StandardMaterial;\r\n /** Material used to render when gizmo is hovered with mouse */\r\n hoverMaterial: StandardMaterial;\r\n /** Color used to render the drag angle sector when gizmo is rotated with mouse */\r\n rotationColor: Color3;\r\n /** Material used to render when gizmo is disabled. typically grey. */\r\n disableMaterial: StandardMaterial;\r\n}\r\n\r\n/**\r\n * Single plane rotation gizmo\r\n */\r\nexport class PlaneRotationGizmo extends Gizmo implements IPlaneRotationGizmo {\r\n /**\r\n * Drag behavior responsible for the gizmos dragging interactions\r\n */\r\n public dragBehavior: PointerDragBehavior;\r\n protected _pointerObserver: Nullable<Observer<PointerInfo>> = null;\r\n\r\n /**\r\n * Rotation distance in radians that the gizmo will snap to (Default: 0)\r\n */\r\n public snapDistance = 0;\r\n /**\r\n * Event that fires each time the gizmo snaps to a new location.\r\n * * snapDistance is the change in distance\r\n */\r\n public onSnapObservable = new Observable<{ snapDistance: number }>();\r\n\r\n /**\r\n * The maximum angle between the camera and the rotation allowed for interaction\r\n * If a rotation plane appears 'flat', a lower value allows interaction.\r\n */\r\n public static MaxDragAngle: number = (Math.PI * 9) / 20;\r\n\r\n /**\r\n * Accumulated relative angle value for rotation on the axis. Reset to 0 when a dragStart occurs\r\n */\r\n public angle: number = 0;\r\n\r\n /**\r\n * Custom sensitivity value for the drag strength\r\n */\r\n public sensitivity = 1;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n public get coloredMaterial() {\r\n return this._coloredMaterial;\r\n }\r\n\r\n /** Material used to render when gizmo is hovered with mouse */\r\n public get hoverMaterial() {\r\n return this._hoverMaterial;\r\n }\r\n\r\n /** Color used to render the drag angle sector when gizmo is rotated with mouse */\r\n public set rotationColor(color: Color3) {\r\n this._rotationShaderMaterial.setColor3(\"rotationColor\", color);\r\n }\r\n\r\n /** Material used to render when gizmo is disabled. typically grey. */\r\n public get disableMaterial() {\r\n return this._disableMaterial;\r\n }\r\n\r\n protected _isEnabled: boolean = true;\r\n protected _parent: Nullable<RotationGizmo> = null;\r\n protected _coloredMaterial: StandardMaterial;\r\n protected _hoverMaterial: StandardMaterial;\r\n protected _disableMaterial: StandardMaterial;\r\n protected _gizmoMesh: Mesh;\r\n protected _rotationDisplayPlane: Mesh;\r\n protected _dragging: boolean = false;\r\n protected _angles = new Vector3();\r\n\r\n protected static _RotationGizmoVertexShader = `\r\n precision highp float;\r\n attribute vec3 position;\r\n attribute vec2 uv;\r\n uniform mat4 worldViewProjection;\r\n varying vec3 vPosition;\r\n varying vec2 vUV;\r\n\r\n void main(void) {\r\n gl_Position = worldViewProjection * vec4(position, 1.0);\r\n vUV = uv;\r\n }`;\r\n\r\n protected static _RotationGizmoFragmentShader = `\r\n precision highp float;\r\n varying vec2 vUV;\r\n varying vec3 vPosition;\r\n uniform vec3 angles;\r\n uniform vec3 rotationColor;\r\n\r\n #define twopi 6.283185307\r\n\r\n void main(void) {\r\n vec2 uv = vUV - vec2(0.5);\r\n float angle = atan(uv.y, uv.x) + 3.141592;\r\n float delta = gl_FrontFacing ? angles.y : -angles.y;\r\n float begin = angles.x - delta * angles.z;\r\n float start = (begin < (begin + delta)) ? begin : (begin + delta);\r\n float end = (begin > (begin + delta)) ? begin : (begin + delta);\r\n float len = sqrt(dot(uv,uv));\r\n float opacity = 1. - step(0.5, len);\r\n\r\n float base = abs(floor(start / twopi)) * twopi;\r\n start += base;\r\n end += base;\r\n\r\n float intensity = 0.;\r\n for (int i = 0; i < 5; i++)\r\n {\r\n intensity += max(step(start, angle) - step(end, angle), 0.);\r\n angle += twopi;\r\n }\r\n gl_FragColor = vec4(rotationColor, min(intensity * 0.25, 0.8)) * opacity;\r\n }\r\n `;\r\n\r\n protected _rotationShaderMaterial: ShaderMaterial;\r\n\r\n /**\r\n * Creates a PlaneRotationGizmo\r\n * @param planeNormal The normal of the plane which the gizmo will be able to rotate on\r\n * @param color The color of the gizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n * @param tessellation Amount of tessellation to be used when creating rotation circles\r\n * @param parent\r\n * @param useEulerRotation Use and update Euler angle instead of quaternion\r\n * @param thickness display gizmo axis thickness\r\n * @param hoverColor The color of the gizmo when hovering over and dragging\r\n * @param disableColor The Color of the gizmo when its disabled\r\n */\r\n constructor(\r\n planeNormal: Vector3,\r\n color: Color3 = Color3.Gray(),\r\n gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer,\r\n tessellation = 32,\r\n parent: Nullable<RotationGizmo> = null,\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n useEulerRotation = false,\r\n thickness: number = 1,\r\n hoverColor: Color3 = Color3.Yellow(),\r\n disableColor: Color3 = Color3.Gray()\r\n ) {\r\n super(gizmoLayer);\r\n this._parent = parent;\r\n // Create Material\r\n this._coloredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._coloredMaterial.diffuseColor = color;\r\n this._coloredMaterial.specularColor = color.subtract(new Color3(0.1, 0.1, 0.1));\r\n\r\n this._hoverMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._hoverMaterial.diffuseColor = hoverColor;\r\n this._hoverMaterial.specularColor = hoverColor;\r\n\r\n this._disableMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._disableMaterial.diffuseColor = disableColor;\r\n this._disableMaterial.alpha = 0.4;\r\n\r\n // Build mesh on root node\r\n this._gizmoMesh = new Mesh(\"\", gizmoLayer.utilityLayerScene);\r\n const { rotationMesh, collider } = this._createGizmoMesh(this._gizmoMesh, thickness, tessellation);\r\n\r\n // Setup Rotation Circle\r\n this._rotationDisplayPlane = CreatePlane(\r\n \"rotationDisplay\",\r\n {\r\n size: 0.6,\r\n updatable: false,\r\n },\r\n this.gizmoLayer.utilityLayerScene\r\n );\r\n this._rotationDisplayPlane.rotation.z = Math.PI * 0.5;\r\n this._rotationDisplayPlane.parent = this._gizmoMesh;\r\n this._rotationDisplayPlane.setEnabled(false);\r\n\r\n Effect.ShadersStore[\"rotationGizmoVertexShader\"] = PlaneRotationGizmo._RotationGizmoVertexShader;\r\n Effect.ShadersStore[\"rotationGizmoFragmentShader\"] = PlaneRotationGizmo._RotationGizmoFragmentShader;\r\n this._rotationShaderMaterial = new ShaderMaterial(\r\n \"shader\",\r\n this.gizmoLayer.utilityLayerScene,\r\n {\r\n vertex: \"rotationGizmo\",\r\n fragment: \"rotationGizmo\",\r\n },\r\n {\r\n attributes: [\"position\", \"uv\"],\r\n uniforms: [\"worldViewProjection\", \"angles\", \"rotationColor\"],\r\n }\r\n );\r\n this._rotationShaderMaterial.backFaceCulling = false;\r\n this.rotationColor = hoverColor;\r\n\r\n this._rotationDisplayPlane.material = this._rotationShaderMaterial;\r\n this._rotationDisplayPlane.visibility = 0.999;\r\n\r\n this._gizmoMesh.lookAt(this._rootMesh.position.add(planeNormal));\r\n this._rootMesh.addChild(this._gizmoMesh, Gizmo.PreserveScaling);\r\n this._gizmoMesh.scaling.scaleInPlace(1 / 3);\r\n // Add drag behavior to handle events when the gizmo is dragged\r\n this.dragBehavior = new PointerDragBehavior({ dragPlaneNormal: planeNormal });\r\n this.dragBehavior.moveAttached = false;\r\n this.dragBehavior.maxDragAngle = PlaneRotationGizmo.MaxDragAngle;\r\n this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;\r\n this._rootMesh.addBehavior(this.dragBehavior);\r\n\r\n // Closures for drag logic\r\n const lastDragPosition = new Vector3();\r\n\r\n const rotationMatrix = new Matrix();\r\n const planeNormalTowardsCamera = new Vector3();\r\n let localPlaneNormalTowardsCamera = new Vector3();\r\n\r\n this.dragBehavior.onDragStartObservable.add((e) => {\r\n if (this.attachedNode) {\r\n if (this._additionalTransformNode) {\r\n this._additionalTransformNode.getWorldMatrix().invertToRef(TmpVectors.Matrix[0]);\r\n Vector3.TransformCoordinatesToRef(e.dragPlanePoint, TmpVectors.Matrix[0], e.dragPlanePoint);\r\n }\r\n lastDragPosition.copyFrom(e.dragPlanePoint);\r\n this._rotationDisplayPlane.setEnabled(true);\r\n\r\n this._rotationDisplayPlane.getWorldMatrix().invertToRef(rotationMatrix);\r\n Vector3.TransformCoordinatesToRef(e.dragPlanePoint, rotationMatrix, lastDragPosition);\r\n\r\n this._angles.x = Math.atan2(lastDragPosition.y, lastDragPosition.x) + Math.PI;\r\n this._angles.y = 0;\r\n this._angles.z = this.updateGizmoRotationToMatchAttachedMesh ? 1 : 0;\r\n this._dragging = true;\r\n lastDragPosition.copyFrom(e.dragPlanePoint);\r\n this._rotationShaderMaterial.setVector3(\"angles\", this._angles);\r\n this.angle = 0;\r\n // there is an issue with the rotation plane with additionalTransformNode, so we hide it in that case to avoid confusion\r\n this._rotationDisplayPlane.visibility = this._additionalTransformNode ? 0 : 0.999;\r\n }\r\n });\r\n\r\n this.dragBehavior.onDragEndObservable.add(() => {\r\n this._dragging = false;\r\n this._rotationDisplayPlane.setEnabled(false);\r\n });\r\n\r\n const tmpSnapEvent = { snapDistance: 0 };\r\n let currentSnapDragDistance = 0;\r\n const tmpMatrix = new Matrix();\r\n const amountToRotate = new Quaternion();\r\n this.dragBehavior.onDragObservable.add((event) => {\r\n if (this.attachedNode) {\r\n // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)\r\n const nodeScale = new Vector3(1, 1, 1);\r\n const nodeQuaternion = new Quaternion(0, 0, 0, 1);\r\n const nodeTranslation = new Vector3(0, 0, 0);\r\n const attachedNodeTransform = this._attachedNode as TransformNode;\r\n // check there is an active pivot for the TransformNode attached\r\n if (attachedNodeTransform && attachedNodeTransform.isUsingPivotMatrix && attachedNodeTransform.isUsingPivotMatrix() && attachedNodeTransform.position) {\r\n // When a TransformNode has an active pivot, even without parenting,\r\n // translation from the world matrix is different from TransformNode.position.\r\n // Pivot works like a virtual parent that's using the node orientation.\r\n // As the world matrix is transformed by the gizmo and then decomposed to TRS\r\n // its translation part must be set to the Node's position.\r\n attachedNodeTransform.getWorldMatrix().setTranslation(attachedNodeTransform.position);\r\n }\r\n\r\n this.attachedNode.getWorldMatrix().decompose(nodeScale, nodeQuaternion, nodeTranslation);\r\n // uniform scaling of absolute value of components\r\n // (-1,1,1) is uniform but (1,1.001,1) is not\r\n const uniformScaling = Math.abs(Math.abs(nodeScale.x) - Math.abs(nodeScale.y)) <= Epsilon && Math.abs(Math.abs(nodeScale.x) - Math.abs(nodeScale.z)) <= Epsilon;\r\n if (!uniformScaling && this.updateGizmoRotationToMatchAttachedMesh) {\r\n Logger.Warn(\r\n \"Unable to use a rotation gizmo matching mesh rotation with non uniform scaling. Use uniform scaling or set updateGizmoRotationToMatchAttachedMesh to false.\"\r\n );\r\n return;\r\n }\r\n nodeQuaternion.normalize();\r\n\r\n const nodeTranslationForOperation = this.updateGizmoPositionToMatchAttachedMesh ? nodeTranslation : this._rootMesh.absolutePosition;\r\n if (this._additionalTransformNode) {\r\n this._additionalTransformNode.getWorldMatrix().invertToRef(TmpVectors.Matrix[0]);\r\n Vector3.TransformCoordinatesToRef(event.dragPlanePoint, TmpVectors.Matrix[0], event.dragPlanePoint);\r\n }\r\n const newVector = event.dragPlanePoint.subtract(nodeTranslationForOperation).normalize();\r\n const originalVector = lastDragPosition.subtract(nodeTranslationForOperation).normalize();\r\n const cross = Vector3.Cross(newVector, originalVector);\r\n const dot = Vector3.Dot(newVector, originalVector);\r\n let angle = Math.atan2(cross.length(), dot) * this.sensitivity;\r\n planeNormalTowardsCamera.copyFrom(planeNormal);\r\n localPlaneNormalTowardsCamera.copyFrom(planeNormal);\r\n if (this.updateGizmoRotationToMatchAttachedMesh) {\r\n nodeQuaternion.toRotationMatrix(rotationMatrix);\r\n localPlaneNormalTowardsCamera = Vector3.TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);\r\n }\r\n // Flip up vector depending on which side the camera is on\r\n let cameraFlipped = false;\r\n if (gizmoLayer.utilityLayerScene.activeCamera) {\r\n const camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(nodeTranslationForOperation).normalize();\r\n if (Vector3.Dot(camVec, localPlaneNormalTowardsCamera) > 0) {\r\n planeNormalTowardsCamera.scaleInPlace(-1);\r\n localPlaneNormalTowardsCamera.scaleInPlace(-1);\r\n cameraFlipped = true;\r\n }\r\n }\r\n const halfCircleSide = Vector3.Dot(localPlaneNormalTowardsCamera, cross) > 0.0;\r\n if (halfCircleSide) {\r\n angle = -angle;\r\n }\r\n\r\n TmpVectors.Vector3[0].set(angle, 0, 0);\r\n if (!this.dragBehavior.validateDrag(TmpVectors.Vector3[0])) {\r\n angle = 0;\r\n }\r\n\r\n // Snapping logic\r\n let snapped = false;\r\n if (this.snapDistance != 0) {\r\n currentSnapDragDistance += angle;\r\n if (Math.abs(currentSnapDragDistance) > this.snapDistance) {\r\n let dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / this.snapDistance);\r\n if (currentSnapDragDistance < 0) {\r\n dragSteps *= -1;\r\n }\r\n currentSnapDragDistance = currentSnapDragDistance % this.snapDistance;\r\n angle = this.snapDistance * dragSteps;\r\n snapped = true;\r\n } else {\r\n angle = 0;\r\n }\r\n }\r\n\r\n // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)\r\n const quaternionCoefficient = Math.sin(angle / 2);\r\n amountToRotate.set(\r\n planeNormalTowardsCamera.x * quaternionCoefficient,\r\n planeNormalTowardsCamera.y * quaternionCoefficient,\r\n planeNormalTowardsCamera.z * quaternionCoefficient,\r\n Math.cos(angle / 2)\r\n );\r\n\r\n // If the meshes local scale is inverted (eg. loaded gltf file parent with z scale of -1) the rotation needs to be inverted on the y axis\r\n if (tmpMatrix.determinant() > 0) {\r\n const tmpVector = new Vector3();\r\n amountToRotate.toEulerAnglesToRef(tmpVector);\r\n Quaternion.RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);\r\n }\r\n\r\n if (this.updateGizmoRotationToMatchAttachedMesh) {\r\n // Rotate selected mesh quaternion over fixed axis\r\n nodeQuaternion.multiplyToRef(amountToRotate, nodeQuaternion);\r\n nodeQuaternion.normalize();\r\n // recompose matrix\r\n Matrix.ComposeToRef(nodeScale, nodeQuaternion, nodeTranslation, this.attachedNode.getWorldMatrix());\r\n } else {\r\n // Rotate selected mesh quaternion over rotated axis\r\n amountToRotate.toRotationMatrix(TmpVectors.Matrix[0]);\r\n const translation = this.attachedNode.getWorldMatrix().getTranslation();\r\n this.attachedNode.getWorldMatrix().multiplyToRef(TmpVectors.Matrix[0], this.attachedNode.getWorldMatrix());\r\n this.attachedNode.getWorldMatrix().setTranslation(translation);\r\n }\r\n\r\n lastDragPosition.copyFrom(event.dragPlanePoint);\r\n if (snapped) {\r\n tmpSnapEvent.snapDistance = angle;\r\n this.onSnapObservable.notifyObservers(tmpSnapEvent);\r\n }\r\n this._angles.y += gizmoLayer.utilityLayerScene.useRightHandedSystem ? -angle : angle;\r\n this.angle += cameraFlipped ? -angle : angle;\r\n this._rotationShaderMaterial.setVector3(\"angles\", this._angles);\r\n this._matrixChanged();\r\n }\r\n });\r\n\r\n const light = gizmoLayer._getSharedGizmoLight();\r\n light.includedOnlyMeshes = light.includedOnlyMeshes.concat(this._rootMesh.getChildMeshes(false));\r\n\r\n const cache: GizmoAxisCache = {\r\n colliderMeshes: [collider],\r\n gizmoMeshes: [rotationMesh],\r\n material: this._coloredMaterial,\r\n hoverMaterial: this._hoverMaterial,\r\n disableMaterial: this._disableMaterial,\r\n active: false,\r\n dragBehavior: this.dragBehavior,\r\n };\r\n this._parent?.addToAxisCache(this._gizmoMesh, cache);\r\n\r\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (this._customMeshSet) {\r\n return;\r\n }\r\n // updating here the maxangle because ondragstart is too late (value already used) and the updated value is not taken into account\r\n this.dragBehavior.maxDragAngle = PlaneRotationGizmo.MaxDragAngle;\r\n this._isHovered = !!(cache.colliderMeshes.indexOf(<Mesh>pointerInfo?.pickInfo?.pickedMesh) != -1);\r\n if (!this._parent) {\r\n const material = cache.dragBehavior.enabled ? (this._isHovered || this._dragging ? this._hoverMaterial : this._coloredMaterial) : this._disableMaterial;\r\n this._setGizmoMeshMaterial(cache.gizmoMeshes, material);\r\n }\r\n });\r\n\r\n this.dragBehavior.onEnabledObservable.add((newState) => {\r\n this._setGizmoMeshMaterial(cache.gizmoMeshes, newState ? this._coloredMaterial : this._disableMaterial);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n * Create Geometry for Gizmo\r\n * @param parentMesh\r\n * @param thickness\r\n * @param tessellation\r\n * @returns\r\n */\r\n protected _createGizmoMesh(parentMesh: AbstractMesh, thickness: number, tessellation: number) {\r\n const collider = CreateTorus(\r\n \"ignore\",\r\n {\r\n diameter: 0.6,\r\n thickness: 0.03 * thickness,\r\n tessellation,\r\n },\r\n this.gizmoLayer.utilityLayerScene\r\n );\r\n collider.visibility = 0;\r\n const rotationMesh = CreateTorus(\r\n \"\",\r\n {\r\n diameter: 0.6,\r\n thickness: 0.005 * thickness,\r\n tessellation,\r\n },\r\n this.gizmoLayer.utilityLayerScene\r\n );\r\n rotationMesh.material = this._coloredMaterial;\r\n\r\n // Position arrow pointing in its drag axis\r\n rotationMesh.rotation.x = Math.PI / 2;\r\n collider.rotation.x = Math.PI / 2;\r\n\r\n parentMesh.addChild(rotationMesh, Gizmo.PreserveScaling);\r\n parentMesh.addChild(collider, Gizmo.PreserveScaling);\r\n return { rotationMesh, collider };\r\n }\r\n\r\n protected override _attachedNodeChanged(value: Nullable<Node>) {\r\n if (this.dragBehavior) {\r\n this.dragBehavior.enabled = value ? true : false;\r\n }\r\n }\r\n\r\n /**\r\n * If the gizmo is enabled\r\n */\r\n public set isEnabled(value: boolean) {\r\n this._isEnabled = value;\r\n if (!value) {\r\n this.attachedMesh = null;\r\n } else {\r\n if (this._parent) {\r\n this.attachedMesh = this._parent.attachedMesh;\r\n }\r\n }\r\n }\r\n\r\n public get isEnabled(): boolean {\r\n return this._isEnabled;\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo\r\n */\r\n public override dispose() {\r\n this.onSnapObservable.clear();\r\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\r\n this.dragBehavior.detach();\r\n if (this._gizmoMesh) {\r\n this._gizmoMesh.dispose();\r\n }\r\n if (this._rotationDisplayPlane) {\r\n this._rotationDisplayPlane.dispose();\r\n }\r\n if (this._rotationShaderMaterial) {\r\n this._rotationShaderMaterial.dispose();\r\n }\r\n const materials = [this._coloredMaterial, this._hoverMaterial, this._disableMaterial];\r\n for (const matl of materials) {\r\n if (matl) {\r\n matl.dispose();\r\n }\r\n }\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -69,10 +69,16 @@ export class NodeMaterialTeleportOutBlock extends NodeMaterialBlock {
|
|
|
69
69
|
state.compilationString += state._declareOutput(this.output) + ` = ${this.entryPoint.input.associatedVariableName};\n`;
|
|
70
70
|
if (this.entryPoint.endpoints.length > 1) {
|
|
71
71
|
// Check if all the endpoints are in the same shader stage
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
const firstConnected = this.entryPoint.endpoints.find((e) => e.output.isConnected);
|
|
73
|
+
if (firstConnected) {
|
|
74
|
+
const firstTarget = firstConnected.output.isConnectedInVertexShader;
|
|
75
|
+
for (const endpoint of this.entryPoint.endpoints) {
|
|
76
|
+
if (endpoint === firstConnected) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (endpoint.output.isConnected && endpoint.output.isConnectedInVertexShader !== firstTarget) {
|
|
80
|
+
state.sharedData.raiseBuildError(`TeleportInBlock "${this.entryPoint.name}" cannot have outputs in different shader stages. All the outputs must be in the same shader stage (vertex or fragment but not both).`);
|
|
81
|
+
}
|
|
76
82
|
}
|
|
77
83
|
}
|
|
78
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"teleportOutBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/Teleport/teleportOutBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAG1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAGhF;;GAEG;AACH,MAAM,OAAO,4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AAQ,IAAI,EAAE,CAAC;QAEjE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACa,YAAY,CAAC,mBAAwB,EAAE,KAAY,EAAE,OAAe;QAChF,KAAK,CAAC,YAAY,CAAC,mBAAmB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAExD,IAAI,CAAC,uBAAuB,GAAG,mBAAmB,CAAC,UAAU,CAAC;IAClE,CAAC;CACJ;AAED,aAAa,CAAC,sCAAsC,EAAE,4BAA4B,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../../../types\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { NodeMaterialTeleportInBlock } from \"./teleportInBlock\";\r\nimport { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\n\r\n/**\r\n * Defines a block used to receive a value from a teleport entry point\r\n */\r\nexport class NodeMaterialTeleportOutBlock extends NodeMaterialBlock {\r\n /** @internal */\r\n public _entryPoint: Nullable<NodeMaterialTeleportInBlock> = null;\r\n /** @internal */\r\n public _tempEntryPointUniqueId: Nullable<number> = null;\r\n\r\n /**\r\n * Create a new TeleportOutBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.BasedOnInput);\r\n }\r\n\r\n /**\r\n * Gets the entry point\r\n */\r\n public get entryPoint() {\r\n return this._entryPoint;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"NodeMaterialTeleportOutBlock\";\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets or sets the target of the block\r\n */\r\n public override get target() {\r\n return this._entryPoint ? this._entryPoint.target : this._target;\r\n }\r\n\r\n public override set target(value: NodeMaterialBlockTargets) {\r\n if ((this._target & value) !== 0) {\r\n return;\r\n }\r\n this._target = value;\r\n }\r\n\r\n /** Detach from entry point */\r\n public detach() {\r\n if (!this._entryPoint) {\r\n return;\r\n }\r\n\r\n this._entryPoint.detachFromEndpoint(this);\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (!this.entryPoint) {\r\n return;\r\n }\r\n\r\n if (this.entryPoint.isConnectedToUniform) {\r\n // We skip the build if the entry point is connected to a uniform\r\n this.output.associatedVariableName = this.entryPoint.input.associatedVariableName;\r\n return;\r\n }\r\n\r\n state.compilationString += state._declareOutput(this.output) + ` = ${this.entryPoint.input.associatedVariableName};\\n`;\r\n\r\n if (this.entryPoint.endpoints.length > 1) {\r\n // Check if all the endpoints are in the same shader stage\r\n const firstTarget = this.entryPoint.endpoints[0].output.isConnectedInVertexShader;\r\n for (let i = 1; i < this.entryPoint.endpoints.length; i++) {\r\n if (this.entryPoint.endpoints[i].output.isConnectedInVertexShader !== firstTarget) {\r\n state.sharedData.raiseBuildError(\r\n `TeleportInBlock \"${this.entryPoint.name}\" cannot have outputs in different shader stages. All the outputs must be in the same shader stage (vertex or fragment but not both).`\r\n );\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clone the current block to a new identical block\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a copy of the current block\r\n */\r\n public override clone(scene: Scene, rootUrl: string = \"\") {\r\n const clone = super.clone(scene, rootUrl);\r\n\r\n if (this.entryPoint) {\r\n this.entryPoint.attachToEndpoint(clone as NodeMaterialTeleportOutBlock);\r\n }\r\n\r\n return clone;\r\n }\r\n\r\n protected override _customBuildStep(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): void {\r\n if (this.entryPoint) {\r\n this.entryPoint.build(state, activeBlocks);\r\n }\r\n }\r\n\r\n /**\r\n * Dumps the code for the block\r\n * @param uniqueNames - the unique names\r\n * @param alreadyDumped - the already dumped blocks\r\n * @returns the code string\r\n */\r\n public override _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]) {\r\n let codeString: string = \"\";\r\n if (this.entryPoint) {\r\n if (alreadyDumped.indexOf(this.entryPoint) === -1) {\r\n codeString += this.entryPoint._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n }\r\n\r\n return codeString + super._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n\r\n /**\r\n * Dumps the code for output connections\r\n * @param alreadyDumped - the already dumped blocks\r\n * @returns the code string\r\n */\r\n public override _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]) {\r\n let codeString = super._dumpCodeForOutputConnections(alreadyDumped);\r\n\r\n if (this.entryPoint) {\r\n codeString += this.entryPoint._dumpCodeForOutputConnections(alreadyDumped);\r\n }\r\n\r\n return codeString;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n\r\n if (this.entryPoint) {\r\n codeString += `${this.entryPoint._codeVariableName}.attachToEndpoint(${this._codeVariableName});\\n`;\r\n }\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.entryPoint = this.entryPoint?.uniqueId ?? \"\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Deserializes the block\r\n * @param serializationObject - the serialization object\r\n * @param scene - the scene\r\n * @param rootUrl - the root URL\r\n */\r\n public override _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this._tempEntryPointUniqueId = serializationObject.entryPoint;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.NodeMaterialTeleportOutBlock\", NodeMaterialTeleportOutBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"teleportOutBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Materials/Node/Blocks/Teleport/teleportOutBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAG1G,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAGhF;;GAEG;AACH,MAAM,OAAO,4BAA6B,SAAQ,iBAAiB;IAM/D;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,CAAC;QAVlD,gBAAgB;QACT,gBAAW,GAA0C,IAAI,CAAC;QACjE,gBAAgB;QACT,4BAAuB,GAAqB,IAAI,CAAC;QASpD,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,YAAY,CAAC,CAAC;IACtF,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,8BAA8B,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,IAAoB,MAAM;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;IACr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CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACa,6BAA6B,CAAC,aAAkC;QAC5E,IAAI,UAAU,GAAG,KAAK,CAAC,6BAA6B,CAAC,aAAa,CAAC,CAAC;QAEpE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,UAAU,IAAI,IAAI,CAAC,UAAU,CAAC,6BAA6B,CAAC,aAAa,CAAC,CAAC;QAC/E,CAAC;QAED,OAAO,UAAU,CAAC;IACtB,CAAC;IAEkB,mBAAmB;QAClC,IAAI,UAAU,GAAG,KAAK,CAAC,mBAAmB,EAAE,CAAC;QAE7C,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,UAAU,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,iBAAiB,qBAAqB,IAAI,CAAC,iBAAiB,MAAM,CAAC;QACxG,CAAC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED;;;OAGG;IACa,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,IAAI,EAAE,CAAC;QAEjE,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACa,YAAY,CAAC,mBAAwB,EAAE,KAAY,EAAE,OAAe;QAChF,KAAK,CAAC,YAAY,CAAC,mBAAmB,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAExD,IAAI,CAAC,uBAAuB,GAAG,mBAAmB,CAAC,UAAU,CAAC;IAClE,CAAC;CACJ;AAED,aAAa,CAAC,sCAAsC,EAAE,4BAA4B,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../../../types\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { NodeMaterialTeleportInBlock } from \"./teleportInBlock\";\r\nimport { NodeMaterialBlock } from \"../../nodeMaterialBlock\";\r\nimport { NodeMaterialBlockConnectionPointTypes } from \"../../Enums/nodeMaterialBlockConnectionPointTypes\";\r\nimport type { NodeMaterialConnectionPoint } from \"../../nodeMaterialBlockConnectionPoint\";\r\nimport type { Scene } from \"../../../../scene\";\r\nimport { NodeMaterialBlockTargets } from \"../../Enums/nodeMaterialBlockTargets\";\r\nimport type { NodeMaterialBuildState } from \"../../nodeMaterialBuildState\";\r\n\r\n/**\r\n * Defines a block used to receive a value from a teleport entry point\r\n */\r\nexport class NodeMaterialTeleportOutBlock extends NodeMaterialBlock {\r\n /** @internal */\r\n public _entryPoint: Nullable<NodeMaterialTeleportInBlock> = null;\r\n /** @internal */\r\n public _tempEntryPointUniqueId: Nullable<number> = null;\r\n\r\n /**\r\n * Create a new TeleportOutBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name, NodeMaterialBlockTargets.Neutral);\r\n\r\n this.registerOutput(\"output\", NodeMaterialBlockConnectionPointTypes.BasedOnInput);\r\n }\r\n\r\n /**\r\n * Gets the entry point\r\n */\r\n public get entryPoint() {\r\n return this._entryPoint;\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"NodeMaterialTeleportOutBlock\";\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeMaterialConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets or sets the target of the block\r\n */\r\n public override get target() {\r\n return this._entryPoint ? this._entryPoint.target : this._target;\r\n }\r\n\r\n public override set target(value: NodeMaterialBlockTargets) {\r\n if ((this._target & value) !== 0) {\r\n return;\r\n }\r\n this._target = value;\r\n }\r\n\r\n /** Detach from entry point */\r\n public detach() {\r\n if (!this._entryPoint) {\r\n return;\r\n }\r\n\r\n this._entryPoint.detachFromEndpoint(this);\r\n }\r\n\r\n protected override _buildBlock(state: NodeMaterialBuildState) {\r\n super._buildBlock(state);\r\n\r\n if (!this.entryPoint) {\r\n return;\r\n }\r\n\r\n if (this.entryPoint.isConnectedToUniform) {\r\n // We skip the build if the entry point is connected to a uniform\r\n this.output.associatedVariableName = this.entryPoint.input.associatedVariableName;\r\n return;\r\n }\r\n\r\n state.compilationString += state._declareOutput(this.output) + ` = ${this.entryPoint.input.associatedVariableName};\\n`;\r\n\r\n if (this.entryPoint.endpoints.length > 1) {\r\n // Check if all the endpoints are in the same shader stage\r\n const firstConnected = this.entryPoint.endpoints.find((e) => e.output.isConnected);\r\n if (firstConnected) {\r\n const firstTarget = firstConnected.output.isConnectedInVertexShader;\r\n for (const endpoint of this.entryPoint.endpoints) {\r\n if (endpoint === firstConnected) {\r\n continue;\r\n }\r\n if (endpoint.output.isConnected && endpoint.output.isConnectedInVertexShader !== firstTarget) {\r\n state.sharedData.raiseBuildError(\r\n `TeleportInBlock \"${this.entryPoint.name}\" cannot have outputs in different shader stages. All the outputs must be in the same shader stage (vertex or fragment but not both).`\r\n );\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clone the current block to a new identical block\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root URL to use to load textures and relative dependencies\r\n * @returns a copy of the current block\r\n */\r\n public override clone(scene: Scene, rootUrl: string = \"\") {\r\n const clone = super.clone(scene, rootUrl);\r\n\r\n if (this.entryPoint) {\r\n this.entryPoint.attachToEndpoint(clone as NodeMaterialTeleportOutBlock);\r\n }\r\n\r\n return clone;\r\n }\r\n\r\n protected override _customBuildStep(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): void {\r\n if (this.entryPoint) {\r\n this.entryPoint.build(state, activeBlocks);\r\n }\r\n }\r\n\r\n /**\r\n * Dumps the code for the block\r\n * @param uniqueNames - the unique names\r\n * @param alreadyDumped - the already dumped blocks\r\n * @returns the code string\r\n */\r\n public override _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]) {\r\n let codeString: string = \"\";\r\n if (this.entryPoint) {\r\n if (alreadyDumped.indexOf(this.entryPoint) === -1) {\r\n codeString += this.entryPoint._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n }\r\n\r\n return codeString + super._dumpCode(uniqueNames, alreadyDumped);\r\n }\r\n\r\n /**\r\n * Dumps the code for output connections\r\n * @param alreadyDumped - the already dumped blocks\r\n * @returns the code string\r\n */\r\n public override _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]) {\r\n let codeString = super._dumpCodeForOutputConnections(alreadyDumped);\r\n\r\n if (this.entryPoint) {\r\n codeString += this.entryPoint._dumpCodeForOutputConnections(alreadyDumped);\r\n }\r\n\r\n return codeString;\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode();\r\n\r\n if (this.entryPoint) {\r\n codeString += `${this.entryPoint._codeVariableName}.attachToEndpoint(${this._codeVariableName});\\n`;\r\n }\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.entryPoint = this.entryPoint?.uniqueId ?? \"\";\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Deserializes the block\r\n * @param serializationObject - the serialization object\r\n * @param scene - the scene\r\n * @param rootUrl - the root URL\r\n */\r\n public override _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {\r\n super._deserialize(serializationObject, scene, rootUrl);\r\n\r\n this._tempEntryPointUniqueId = serializationObject.entryPoint;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.NodeMaterialTeleportOutBlock\", NodeMaterialTeleportOutBlock);\r\n"]}
|
|
@@ -61,38 +61,46 @@ export function _ProcessShaderCode(processorOptions, baseName, processFinalCode,
|
|
|
61
61
|
else {
|
|
62
62
|
fragmentSource = baseName.fragment || baseName;
|
|
63
63
|
}
|
|
64
|
+
// Important:
|
|
65
|
+
// The vertex shader must be compiled before the fragment shader, as processing the fragment shader may require information from the vertex shader.
|
|
66
|
+
// Also, they should be processed in the same JS tick because the shader processor is a singleton and stores information about the current processing in its internal state.
|
|
67
|
+
// Processing the vertex and fragment shaders in different ticks may cause issues as the internal state may be overridden by another shader being processed in between.
|
|
68
|
+
// This means that the shaders must be processed in sequence and synchronously, but the loading of the shader code can be done in parallel
|
|
69
|
+
// as long as we wait for both shaders to be loaded before starting the processing.
|
|
64
70
|
const shaderCodes = [undefined, undefined];
|
|
65
71
|
const shadersLoaded = () => {
|
|
66
72
|
if (shaderCodes[0] && shaderCodes[1]) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Process(
|
|
73
|
+
const [vertexCode, fragmentCode] = shaderCodes;
|
|
74
|
+
Initialize(processorOptions);
|
|
75
|
+
Process(vertexCode, processorOptions, (migratedVertexCode, codeBeforeMigration) => {
|
|
70
76
|
if (effectContext) {
|
|
71
|
-
effectContext.
|
|
77
|
+
effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;
|
|
72
78
|
}
|
|
73
79
|
if (processFinalCode) {
|
|
74
|
-
|
|
80
|
+
migratedVertexCode = processFinalCode("vertex", migratedVertexCode);
|
|
75
81
|
}
|
|
76
|
-
|
|
77
|
-
processorOptions
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
processorOptions.isFragment = true;
|
|
83
|
+
Process(fragmentCode, processorOptions, (migratedFragmentCode, codeBeforeMigration) => {
|
|
84
|
+
if (effectContext) {
|
|
85
|
+
effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;
|
|
86
|
+
}
|
|
87
|
+
if (processFinalCode) {
|
|
88
|
+
migratedFragmentCode = processFinalCode("fragment", migratedFragmentCode);
|
|
89
|
+
}
|
|
90
|
+
const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);
|
|
91
|
+
processorOptions = null;
|
|
92
|
+
const finalCode = UseFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);
|
|
93
|
+
onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);
|
|
94
|
+
}, engine);
|
|
80
95
|
}, engine);
|
|
81
96
|
}
|
|
82
97
|
};
|
|
83
98
|
LoadShader(vertexSource, "Vertex", "", (vertexCode) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
if (processFinalCode) {
|
|
91
|
-
migratedVertexCode = processFinalCode("vertex", migratedVertexCode);
|
|
92
|
-
}
|
|
93
|
-
shaderCodes[0] = migratedVertexCode;
|
|
94
|
-
shadersLoaded();
|
|
95
|
-
}, engine);
|
|
99
|
+
if (effectContext) {
|
|
100
|
+
effectContext._rawVertexSourceCode = vertexCode;
|
|
101
|
+
}
|
|
102
|
+
shaderCodes[0] = vertexCode;
|
|
103
|
+
shadersLoaded();
|
|
96
104
|
}, shaderLanguage);
|
|
97
105
|
LoadShader(fragmentSource, "Fragment", "Pixel", (fragmentCode) => {
|
|
98
106
|
if (effectContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effect.functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iCAAgC;AAIjF,OAAO,EAAE,cAAc,EAAE,2CAA0C;AACnE,OAAO,EAAE,WAAW,EAAE,kCAAiC;AAIvD,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAC1C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,iDAAgD;AACxF,OAAO,EAAE,SAAS,EAAE,+CAA8C;AA+ElE;;;;;;GAMG;AACH,gEAAgE;AAChE,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAAqB;IACjE,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,gEAAgE;AAChE,MAAM,UAAU,mBAAmB,CAAC,QAA0B;IAC1D,MAAM,IAAI,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AAE;IAClB,IAAI,CAAC;QACD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7E,IAAI,WAAW,EAAE,CAAC;YACd,gIAAgI;YAChI,WAAW,CAAC,4BAA4B,GAAG,OAAO,CAAC,0BAA0B,CAAC;QAClF,CAAC;QACD,MAAM,eAAe,GAAqB,OAAO,CAAC,uBAAuB,IAAI,qBAAqB,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;QACpI,eAAe,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QACrC,IAAI,OAAO,CAAC,IAAI,IAAI,WAAW,EAAE,CAAC;YAC9B,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC;QAChE,CAAC;QAED,sEAAsE;QACtE,oGAAoG;QACpG,uBAAuB,CACnB,eAAe,EACf,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,CAAC,CAAC,OAAO,CAAC,WAAW,EACrB,EAAE,EACF,EAAE,EACF,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,yBAAyB,EACjC,EAAE,EACF,GAAG,EAAE;YACD,oCAAoC,CAAC,eAAe,EAAE,GAAG,EAAE;gBACvD,OAAO,CAAC,wBAAwB,EAAE,CAAC,eAAe,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CACJ,CAAC;QAEF,OAAO,eAAe,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { _IProcessingOptions, ShaderCustomProcessingFunction, _IShaderProcessingContext } from \"core/Engines/Processors/shaderProcessingOptions\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"core/Misc/domManagement\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport type { WebGLContext } from \"core/Engines/thinEngine.functions\";\r\nimport { getStateObject } from \"core/Engines/thinEngine.functions\";\r\nimport { ShaderStore } from \"core/Engines/shaderStore\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { Effect, IShaderPath } from \"./effect\";\r\nimport type { IPipelineContext } from \"core/Engines/IPipelineContext\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { Finalize, Initialize, Process } from \"core/Engines/Processors/shaderProcessor\";\r\nimport { _LoadFile } from \"core/Engines/abstractEngine.functions\";\r\nimport type { WebGLPipelineContext } from \"core/Engines/WebGL/webGLPipelineContext\";\r\n\r\n/**\r\n * Options to be used when creating a pipeline\r\n */\r\nexport interface IPipelineGenerationOptions {\r\n /**\r\n * The definition of the shader content.\r\n * Can be either a unified name, name per vertex and frament or the shader code content itself\r\n */\r\n shaderNameOrContent: string | IShaderPath;\r\n /**\r\n * Unique key to identify the pipeline.\r\n * Note that though not mandatory, it's recommended to provide a key to be able to use the automated pipeline loading system.\r\n */\r\n key?: string;\r\n /**\r\n * The list of defines to be used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * If true, the global defines will be added to the defines array\r\n */\r\n addGlobalDefines?: boolean;\r\n /**\r\n * The shader language.\r\n * Defaults to the language suiting the platform name (GLSL for WEBGL2, WGSL for WEBGPU)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n\r\n /**\r\n * The name of the platform to be used when processing the shader\r\n * defaults to WEBGL2\r\n */\r\n platformName?: string /* \"WEBGL2\" | \"WEBGL1\" | \"WEBGPU\" */;\r\n\r\n /**\r\n * extend the processing options when running code processing\r\n */\r\n extendedProcessingOptions?: Partial<_IProcessingOptions>;\r\n\r\n /**\r\n * extend the pipeline generation options\r\n */\r\n extendedCreatePipelineOptions?: Partial<ICreateAndPreparePipelineContextOptions>;\r\n\r\n /**\r\n * If true, generating a new pipeline will return when the pipeline is ready to be used\r\n */\r\n waitForIsReady?: boolean;\r\n\r\n /**\r\n * If true, the pipeline will be created synchronously, even if parallel shader compilation is available\r\n */\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface ICreateAndPreparePipelineContextOptions {\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n shaderProcessingContext: Nullable<_IShaderProcessingContext>;\r\n existingPipelineContext?: Nullable<IPipelineContext>;\r\n name?: string;\r\n rebuildRebind?: (vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void) => void;\r\n onRenderingStateCompiled?: (pipelineContext?: IPipelineContext) => void;\r\n context?: WebGL2RenderingContext | WebGLRenderingContext;\r\n // preparePipeline options\r\n createAsRaw?: boolean;\r\n vertex: string;\r\n fragment: string;\r\n defines: Nullable<string>;\r\n transformFeedbackVaryings: Nullable<string[]>;\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * Get a cached pipeline context\r\n * @param name the pipeline name\r\n * @param context the context to be used when creating the pipeline\r\n * @returns the cached pipeline context if it exists\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function getCachedPipeline(name: string, context: WebGLContext): IPipelineContext | undefined {\r\n const stateObject = getStateObject(context);\r\n return stateObject.cachedPipelines[name];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function resetCachedPipeline(pipeline: IPipelineContext): void {\r\n const name = pipeline._name;\r\n const context = (pipeline as WebGLPipelineContext).context;\r\n if (name && context) {\r\n const stateObject = getStateObject(context);\r\n const cachedPipeline = stateObject.cachedPipelines[name];\r\n cachedPipeline?.dispose();\r\n delete stateObject.cachedPipelines[name];\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _ProcessShaderCode(\r\n processorOptions: _IProcessingOptions,\r\n baseName: any,\r\n processFinalCode?: Nullable<ShaderCustomProcessingFunction>,\r\n onFinalCodeReady?: (vertexCode: string, fragmentCode: string) => void,\r\n shaderLanguage?: ShaderLanguage,\r\n engine?: AbstractEngine,\r\n effectContext?: Effect\r\n) {\r\n let vertexSource: string | HTMLElement | IShaderPath;\r\n let fragmentSource: string | HTMLElement | IShaderPath;\r\n\r\n // const baseName = this.name;\r\n const hostDocument = IsWindowObjectExist() ? engine?.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n vertexSource = baseName;\r\n } else if (baseName.vertexSource) {\r\n vertexSource = \"source:\" + baseName.vertexSource;\r\n } else if (baseName.vertexElement) {\r\n vertexSource = hostDocument?.getElementById(baseName.vertexElement) || baseName.vertexElement;\r\n } else {\r\n vertexSource = baseName.vertex || baseName;\r\n }\r\n if (typeof baseName === \"string\") {\r\n fragmentSource = baseName;\r\n } else if (baseName.fragmentSource) {\r\n fragmentSource = \"source:\" + baseName.fragmentSource;\r\n } else if (baseName.fragmentElement) {\r\n fragmentSource = hostDocument?.getElementById(baseName.fragmentElement) || baseName.fragmentElement;\r\n } else {\r\n fragmentSource = baseName.fragment || baseName;\r\n }\r\n\r\n const shaderCodes: [string | undefined, string | undefined] = [undefined, undefined];\r\n const shadersLoaded = () => {\r\n if (shaderCodes[0] && shaderCodes[1]) {\r\n processorOptions.isFragment = true;\r\n const [migratedVertexCode, fragmentCode] = shaderCodes;\r\n Process(\r\n fragmentCode,\r\n processorOptions,\r\n (migratedFragmentCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedFragmentCode = processFinalCode(\"fragment\", migratedFragmentCode);\r\n }\r\n const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);\r\n processorOptions = null as any;\r\n const finalCode = UseFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);\r\n onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);\r\n },\r\n engine\r\n );\r\n }\r\n };\r\n LoadShader(\r\n vertexSource,\r\n \"Vertex\",\r\n \"\",\r\n (vertexCode) => {\r\n Initialize(processorOptions);\r\n Process(\r\n vertexCode,\r\n processorOptions,\r\n (migratedVertexCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._rawVertexSourceCode = vertexCode;\r\n effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedVertexCode = processFinalCode(\"vertex\", migratedVertexCode);\r\n }\r\n shaderCodes[0] = migratedVertexCode;\r\n shadersLoaded();\r\n },\r\n engine\r\n );\r\n },\r\n shaderLanguage\r\n );\r\n LoadShader(\r\n fragmentSource,\r\n \"Fragment\",\r\n \"Pixel\",\r\n (fragmentCode) => {\r\n if (effectContext) {\r\n effectContext._rawFragmentSourceCode = fragmentCode;\r\n }\r\n shaderCodes[1] = fragmentCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n}\r\n\r\nfunction LoadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void, shaderLanguage?: ShaderLanguage, _loadFileInjection?: typeof _LoadFile) {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substring(0, 7) === \"source:\") {\r\n callback(shader.substring(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substring(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substring(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n const shaderStore = ShaderStore.GetShadersStore(shaderLanguage);\r\n\r\n // Is in local store ?\r\n if (shaderStore[shader + key + \"Shader\"]) {\r\n callback(shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = ShaderStore.GetShadersRepository(shaderLanguage) + shader;\r\n }\r\n _loadFileInjection = _loadFileInjection || _LoadFile;\r\n if (!_loadFileInjection) {\r\n // we got to this point and loadFile was not injected - throw an error\r\n throw new Error(\"loadFileInjection is not defined\");\r\n }\r\n // Vertex shader\r\n _loadFileInjection(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n}\r\n\r\nfunction UseFinalCode(migratedVertexCode: string, migratedFragmentCode: string, baseName: any, shaderLanguage?: ShaderLanguage) {\r\n if (baseName) {\r\n const vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;\r\n const fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;\r\n\r\n return {\r\n vertexSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME vertex:\" + vertex + \"\\n\" + migratedVertexCode,\r\n fragmentSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME fragment:\" + fragment + \"\\n\" + migratedFragmentCode,\r\n };\r\n } else {\r\n return {\r\n vertexSourceCode: migratedVertexCode,\r\n fragmentSourceCode: migratedFragmentCode,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Creates and prepares a pipeline context\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const createAndPreparePipelineContext = (\r\n options: ICreateAndPreparePipelineContextOptions,\r\n createPipelineContext: typeof AbstractEngine.prototype.createPipelineContext,\r\n _preparePipelineContext: typeof AbstractEngine.prototype._preparePipelineContextAsync,\r\n _executeWhenRenderingStateIsCompiled: typeof AbstractEngine.prototype._executeWhenRenderingStateIsCompiled\r\n): IPipelineContext => {\r\n try {\r\n const stateObject = options.context ? getStateObject(options.context) : null;\r\n if (stateObject) {\r\n // will not remove the reference to parallelShaderPrecompile, but will prevent it from being used in the next shader compilation\r\n stateObject.disableParallelShaderCompile = options.disableParallelCompilation;\r\n }\r\n const pipelineContext: IPipelineContext = options.existingPipelineContext || createPipelineContext(options.shaderProcessingContext);\r\n pipelineContext._name = options.name;\r\n if (options.name && stateObject) {\r\n stateObject.cachedPipelines[options.name] = pipelineContext;\r\n }\r\n\r\n // Flagged as async as we may need to delay load some processing tools\r\n // This does not break anything as the execution is waiting for _executeWhenRenderingStateIsCompiled\r\n _preparePipelineContext(\r\n pipelineContext,\r\n options.vertex,\r\n options.fragment,\r\n !!options.createAsRaw,\r\n \"\",\r\n \"\",\r\n options.rebuildRebind,\r\n options.defines,\r\n options.transformFeedbackVaryings,\r\n \"\",\r\n () => {\r\n _executeWhenRenderingStateIsCompiled(pipelineContext, () => {\r\n options.onRenderingStateCompiled?.(pipelineContext);\r\n });\r\n }\r\n );\r\n\r\n return pipelineContext;\r\n } catch (e) {\r\n Logger.Error(\"Error compiling effect\");\r\n throw e;\r\n }\r\n};\r\n"]}
|
|
1
|
+
{"version":3,"file":"effect.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effect.functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iCAAgC;AAIjF,OAAO,EAAE,cAAc,EAAE,2CAA0C;AACnE,OAAO,EAAE,WAAW,EAAE,kCAAiC;AAIvD,OAAO,EAAE,MAAM,EAAE,0BAAyB;AAC1C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,iDAAgD;AACxF,OAAO,EAAE,SAAS,EAAE,+CAA8C;AA+ElE;;;;;;GAMG;AACH,gEAAgE;AAChE,MAAM,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,EAAE;gBACvD,OAAO,CAAC,wBAAwB,EAAE,CAAC,eAAe,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CACJ,CAAC;QAEF,OAAO,eAAe,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { _IProcessingOptions, ShaderCustomProcessingFunction, _IShaderProcessingContext } from \"core/Engines/Processors/shaderProcessingOptions\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"core/Misc/domManagement\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport type { WebGLContext } from \"core/Engines/thinEngine.functions\";\r\nimport { getStateObject } from \"core/Engines/thinEngine.functions\";\r\nimport { ShaderStore } from \"core/Engines/shaderStore\";\r\nimport type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { Effect, IShaderPath } from \"./effect\";\r\nimport type { IPipelineContext } from \"core/Engines/IPipelineContext\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { Finalize, Initialize, Process } from \"core/Engines/Processors/shaderProcessor\";\r\nimport { _LoadFile } from \"core/Engines/abstractEngine.functions\";\r\nimport type { WebGLPipelineContext } from \"core/Engines/WebGL/webGLPipelineContext\";\r\n\r\n/**\r\n * Options to be used when creating a pipeline\r\n */\r\nexport interface IPipelineGenerationOptions {\r\n /**\r\n * The definition of the shader content.\r\n * Can be either a unified name, name per vertex and frament or the shader code content itself\r\n */\r\n shaderNameOrContent: string | IShaderPath;\r\n /**\r\n * Unique key to identify the pipeline.\r\n * Note that though not mandatory, it's recommended to provide a key to be able to use the automated pipeline loading system.\r\n */\r\n key?: string;\r\n /**\r\n * The list of defines to be used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * If true, the global defines will be added to the defines array\r\n */\r\n addGlobalDefines?: boolean;\r\n /**\r\n * The shader language.\r\n * Defaults to the language suiting the platform name (GLSL for WEBGL2, WGSL for WEBGPU)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n\r\n /**\r\n * The name of the platform to be used when processing the shader\r\n * defaults to WEBGL2\r\n */\r\n platformName?: string /* \"WEBGL2\" | \"WEBGL1\" | \"WEBGPU\" */;\r\n\r\n /**\r\n * extend the processing options when running code processing\r\n */\r\n extendedProcessingOptions?: Partial<_IProcessingOptions>;\r\n\r\n /**\r\n * extend the pipeline generation options\r\n */\r\n extendedCreatePipelineOptions?: Partial<ICreateAndPreparePipelineContextOptions>;\r\n\r\n /**\r\n * If true, generating a new pipeline will return when the pipeline is ready to be used\r\n */\r\n waitForIsReady?: boolean;\r\n\r\n /**\r\n * If true, the pipeline will be created synchronously, even if parallel shader compilation is available\r\n */\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface ICreateAndPreparePipelineContextOptions {\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n shaderProcessingContext: Nullable<_IShaderProcessingContext>;\r\n existingPipelineContext?: Nullable<IPipelineContext>;\r\n name?: string;\r\n rebuildRebind?: (vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void) => void;\r\n onRenderingStateCompiled?: (pipelineContext?: IPipelineContext) => void;\r\n context?: WebGL2RenderingContext | WebGLRenderingContext;\r\n // preparePipeline options\r\n createAsRaw?: boolean;\r\n vertex: string;\r\n fragment: string;\r\n defines: Nullable<string>;\r\n transformFeedbackVaryings: Nullable<string[]>;\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * Get a cached pipeline context\r\n * @param name the pipeline name\r\n * @param context the context to be used when creating the pipeline\r\n * @returns the cached pipeline context if it exists\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function getCachedPipeline(name: string, context: WebGLContext): IPipelineContext | undefined {\r\n const stateObject = getStateObject(context);\r\n return stateObject.cachedPipelines[name];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function resetCachedPipeline(pipeline: IPipelineContext): void {\r\n const name = pipeline._name;\r\n const context = (pipeline as WebGLPipelineContext).context;\r\n if (name && context) {\r\n const stateObject = getStateObject(context);\r\n const cachedPipeline = stateObject.cachedPipelines[name];\r\n cachedPipeline?.dispose();\r\n delete stateObject.cachedPipelines[name];\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _ProcessShaderCode(\r\n processorOptions: _IProcessingOptions,\r\n baseName: any,\r\n processFinalCode?: Nullable<ShaderCustomProcessingFunction>,\r\n onFinalCodeReady?: (vertexCode: string, fragmentCode: string) => void,\r\n shaderLanguage?: ShaderLanguage,\r\n engine?: AbstractEngine,\r\n effectContext?: Effect\r\n) {\r\n let vertexSource: string | HTMLElement | IShaderPath;\r\n let fragmentSource: string | HTMLElement | IShaderPath;\r\n\r\n // const baseName = this.name;\r\n const hostDocument = IsWindowObjectExist() ? engine?.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n vertexSource = baseName;\r\n } else if (baseName.vertexSource) {\r\n vertexSource = \"source:\" + baseName.vertexSource;\r\n } else if (baseName.vertexElement) {\r\n vertexSource = hostDocument?.getElementById(baseName.vertexElement) || baseName.vertexElement;\r\n } else {\r\n vertexSource = baseName.vertex || baseName;\r\n }\r\n if (typeof baseName === \"string\") {\r\n fragmentSource = baseName;\r\n } else if (baseName.fragmentSource) {\r\n fragmentSource = \"source:\" + baseName.fragmentSource;\r\n } else if (baseName.fragmentElement) {\r\n fragmentSource = hostDocument?.getElementById(baseName.fragmentElement) || baseName.fragmentElement;\r\n } else {\r\n fragmentSource = baseName.fragment || baseName;\r\n }\r\n\r\n // Important:\r\n // The vertex shader must be compiled before the fragment shader, as processing the fragment shader may require information from the vertex shader.\r\n // Also, they should be processed in the same JS tick because the shader processor is a singleton and stores information about the current processing in its internal state.\r\n // Processing the vertex and fragment shaders in different ticks may cause issues as the internal state may be overridden by another shader being processed in between.\r\n // This means that the shaders must be processed in sequence and synchronously, but the loading of the shader code can be done in parallel\r\n // as long as we wait for both shaders to be loaded before starting the processing.\r\n const shaderCodes: [string | undefined, string | undefined] = [undefined, undefined];\r\n const shadersLoaded = () => {\r\n if (shaderCodes[0] && shaderCodes[1]) {\r\n const [vertexCode, fragmentCode] = shaderCodes;\r\n Initialize(processorOptions);\r\n Process(\r\n vertexCode,\r\n processorOptions,\r\n (migratedVertexCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedVertexCode = processFinalCode(\"vertex\", migratedVertexCode);\r\n }\r\n processorOptions.isFragment = true;\r\n Process(\r\n fragmentCode,\r\n processorOptions,\r\n (migratedFragmentCode: string, codeBeforeMigration: string) => {\r\n if (effectContext) {\r\n effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedFragmentCode = processFinalCode(\"fragment\", migratedFragmentCode);\r\n }\r\n const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);\r\n processorOptions = null as any;\r\n const finalCode = UseFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);\r\n onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);\r\n },\r\n engine\r\n );\r\n },\r\n engine\r\n );\r\n }\r\n };\r\n LoadShader(\r\n vertexSource,\r\n \"Vertex\",\r\n \"\",\r\n (vertexCode) => {\r\n if (effectContext) {\r\n effectContext._rawVertexSourceCode = vertexCode;\r\n }\r\n shaderCodes[0] = vertexCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n LoadShader(\r\n fragmentSource,\r\n \"Fragment\",\r\n \"Pixel\",\r\n (fragmentCode) => {\r\n if (effectContext) {\r\n effectContext._rawFragmentSourceCode = fragmentCode;\r\n }\r\n shaderCodes[1] = fragmentCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n}\r\n\r\nfunction LoadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void, shaderLanguage?: ShaderLanguage, _loadFileInjection?: typeof _LoadFile) {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substring(0, 7) === \"source:\") {\r\n callback(shader.substring(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substring(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substring(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n const shaderStore = ShaderStore.GetShadersStore(shaderLanguage);\r\n\r\n // Is in local store ?\r\n if (shaderStore[shader + key + \"Shader\"]) {\r\n callback(shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = ShaderStore.GetShadersRepository(shaderLanguage) + shader;\r\n }\r\n _loadFileInjection = _loadFileInjection || _LoadFile;\r\n if (!_loadFileInjection) {\r\n // we got to this point and loadFile was not injected - throw an error\r\n throw new Error(\"loadFileInjection is not defined\");\r\n }\r\n // Vertex shader\r\n _loadFileInjection(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n}\r\n\r\nfunction UseFinalCode(migratedVertexCode: string, migratedFragmentCode: string, baseName: any, shaderLanguage?: ShaderLanguage) {\r\n if (baseName) {\r\n const vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;\r\n const fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;\r\n\r\n return {\r\n vertexSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME vertex:\" + vertex + \"\\n\" + migratedVertexCode,\r\n fragmentSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME fragment:\" + fragment + \"\\n\" + migratedFragmentCode,\r\n };\r\n } else {\r\n return {\r\n vertexSourceCode: migratedVertexCode,\r\n fragmentSourceCode: migratedFragmentCode,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Creates and prepares a pipeline context\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const createAndPreparePipelineContext = (\r\n options: ICreateAndPreparePipelineContextOptions,\r\n createPipelineContext: typeof AbstractEngine.prototype.createPipelineContext,\r\n _preparePipelineContext: typeof AbstractEngine.prototype._preparePipelineContextAsync,\r\n _executeWhenRenderingStateIsCompiled: typeof AbstractEngine.prototype._executeWhenRenderingStateIsCompiled\r\n): IPipelineContext => {\r\n try {\r\n const stateObject = options.context ? getStateObject(options.context) : null;\r\n if (stateObject) {\r\n // will not remove the reference to parallelShaderPrecompile, but will prevent it from being used in the next shader compilation\r\n stateObject.disableParallelShaderCompile = options.disableParallelCompilation;\r\n }\r\n const pipelineContext: IPipelineContext = options.existingPipelineContext || createPipelineContext(options.shaderProcessingContext);\r\n pipelineContext._name = options.name;\r\n if (options.name && stateObject) {\r\n stateObject.cachedPipelines[options.name] = pipelineContext;\r\n }\r\n\r\n // Flagged as async as we may need to delay load some processing tools\r\n // This does not break anything as the execution is waiting for _executeWhenRenderingStateIsCompiled\r\n _preparePipelineContext(\r\n pipelineContext,\r\n options.vertex,\r\n options.fragment,\r\n !!options.createAsRaw,\r\n \"\",\r\n \"\",\r\n options.rebuildRebind,\r\n options.defines,\r\n options.transformFeedbackVaryings,\r\n \"\",\r\n () => {\r\n _executeWhenRenderingStateIsCompiled(pipelineContext, () => {\r\n options.onRenderingStateCompiled?.(pipelineContext);\r\n });\r\n }\r\n );\r\n\r\n return pipelineContext;\r\n } catch (e) {\r\n Logger.Error(\"Error compiling effect\");\r\n throw e;\r\n }\r\n};\r\n"]}
|
|
@@ -75,10 +75,14 @@ declare module "./mesh.js" {
|
|
|
75
75
|
* Applies a partial update to a buffer directly on the GPU
|
|
76
76
|
* Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
|
|
77
77
|
* @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
|
|
78
|
-
* @param
|
|
79
|
-
*
|
|
78
|
+
* @param dataOrLength the data to set in the GPU buffer, or the length (in elements) of data to update starting from the offset.
|
|
79
|
+
* If you pass a length (number), it is the number of elements to update. For example, if kind is "matrix" and you pass 2 as length, it will update 2 matrices (2*16 floats) in the GPU buffer starting from the offset; in this case {@link offset} should also be expressed as a number of elements.
|
|
80
|
+
* If you pass a Float32Array, {@link offset} is interpreted in floats in the underlying GPU buffer, consistent with low-level buffer update methods such as updateDirectly.
|
|
81
|
+
* @param offset the offset in the GPU buffer where to update the data:
|
|
82
|
+
* - when {@link dataOrLength} is a number, this is an element offset (for example, a matrix index);
|
|
83
|
+
* - when {@link dataOrLength} is a Float32Array, this is a float offset in the underlying buffer.
|
|
80
84
|
*/
|
|
81
|
-
thinInstancePartialBufferUpdate(kind: string,
|
|
85
|
+
thinInstancePartialBufferUpdate(kind: string, dataOrLength: Float32Array | number, offset: number): void;
|
|
82
86
|
/**
|
|
83
87
|
* Refreshes the bounding info, taking into account all the thin instances defined
|
|
84
88
|
* @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
|
|
@@ -188,10 +188,15 @@ Mesh.prototype.thinInstanceBufferUpdated = function (kind) {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
};
|
|
191
|
-
Mesh.prototype.thinInstancePartialBufferUpdate = function (kind,
|
|
191
|
+
Mesh.prototype.thinInstancePartialBufferUpdate = function (kind, dataOrLength, offset) {
|
|
192
192
|
if (kind === "matrix") {
|
|
193
193
|
if (this._thinInstanceDataStorage.matrixBuffer) {
|
|
194
|
-
|
|
194
|
+
if (typeof dataOrLength === "number") {
|
|
195
|
+
this._thinInstanceDataStorage.matrixBuffer.updateDirectly(new Float32Array(this._thinInstanceDataStorage.matrixData.buffer, this._thinInstanceDataStorage.matrixData.byteOffset + offset * 16 * Float32Array.BYTES_PER_ELEMENT, dataOrLength * 16), offset * 16);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
this._thinInstanceDataStorage.matrixBuffer.updateDirectly(dataOrLength, offset);
|
|
199
|
+
}
|
|
195
200
|
}
|
|
196
201
|
}
|
|
197
202
|
else {
|
|
@@ -200,7 +205,14 @@ Mesh.prototype.thinInstancePartialBufferUpdate = function (kind, data, offset) {
|
|
|
200
205
|
kind = VertexBuffer.ColorInstanceKind;
|
|
201
206
|
}
|
|
202
207
|
if (this._userThinInstanceBuffersStorage?.vertexBuffers[kind]) {
|
|
203
|
-
this._userThinInstanceBuffersStorage.vertexBuffers[kind]
|
|
208
|
+
const buffer = this._userThinInstanceBuffersStorage.vertexBuffers[kind];
|
|
209
|
+
if (typeof dataOrLength === "number") {
|
|
210
|
+
const data = new Float32Array(this._userThinInstanceBuffersStorage.data[kind].buffer, this._userThinInstanceBuffersStorage.data[kind].byteOffset + offset * this._userThinInstanceBuffersStorage.strides[kind] * Float32Array.BYTES_PER_ELEMENT, dataOrLength * this._userThinInstanceBuffersStorage.strides[kind]);
|
|
211
|
+
this._userThinInstanceBuffersStorage.vertexBuffers[kind].updateDirectly(data, offset * this._userThinInstanceBuffersStorage.strides[kind]);
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
buffer.updateDirectly(dataOrLength, offset);
|
|
215
|
+
}
|
|
204
216
|
}
|
|
205
217
|
}
|
|
206
218
|
};
|