@onerjs/core 8.23.12 → 8.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Behaviors/Meshes/index.d.ts +1 -0
- package/Behaviors/Meshes/index.js +1 -0
- package/Behaviors/Meshes/index.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.d.ts +6 -34
- package/Behaviors/Meshes/pointerDragBehavior.js +0 -12
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/pointerDragEvents.d.ts +38 -0
- package/Behaviors/Meshes/pointerDragEvents.js +2 -0
- package/Behaviors/Meshes/pointerDragEvents.js.map +1 -0
- package/Buffers/storageBuffer.d.ts +6 -0
- package/Buffers/storageBuffer.js +8 -0
- package/Buffers/storageBuffer.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.d.ts +2 -1
- package/Engines/Extensions/engine.multiRender.js +12 -7
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.multiview.js +5 -5
- package/Engines/Extensions/engine.multiview.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +2 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +12 -7
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +6 -0
- package/Engines/WebGPU/webgpuDrawContext.js +9 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/abstractEngine.js +3 -3
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +4 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/engineFactory.d.ts +4 -1
- package/Engines/engineFactory.js.map +1 -1
- package/Engines/nativeEngine.js +2 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +2 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +17 -0
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +7 -0
- package/Engines/webgpuEngine.js +19 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +12 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +52 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +0 -3
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +7 -2
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +4 -0
- package/FrameGraph/Tasks/Layers/baseLayerTask.js +7 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +11 -2
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +6 -6
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +27 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +76 -8
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +2 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +0 -7
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderTarget.js +1 -1
- package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
- package/Gizmos/cameraGizmo.js +2 -2
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/lightGizmo.js +2 -2
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.d.ts +7 -6
- package/Gizmos/positionGizmo.js +3 -9
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +7 -6
- package/Gizmos/rotationGizmo.js +3 -9
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +7 -6
- package/Gizmos/scaleGizmo.js +3 -9
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Instrumentation/sceneInstrumentation.d.ts +2 -0
- package/Instrumentation/sceneInstrumentation.js +58 -32
- package/Instrumentation/sceneInstrumentation.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.d.ts +102 -0
- package/Lights/Clustered/clusteredLightContainer.js +487 -0
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.d.ts +34 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.js +47 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.js.map +1 -0
- package/Lights/Clustered/index.d.ts +6 -0
- package/Lights/Clustered/index.js +7 -0
- package/Lights/Clustered/index.js.map +1 -0
- package/Lights/Shadows/cascadedShadowGenerator.js +1 -0
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +10 -8
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/index.d.ts +1 -0
- package/Lights/index.js +1 -0
- package/Lights/index.js.map +1 -1
- package/Lights/light.d.ts +7 -1
- package/Lights/light.js +7 -1
- package/Lights/light.js.map +1 -1
- package/Lights/lightConstants.d.ts +4 -0
- package/Lights/lightConstants.js +4 -0
- package/Lights/lightConstants.js.map +1 -1
- package/Lights/spotLight.d.ts +6 -3
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +0 -5
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +3 -2
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +5 -0
- package/Materials/Textures/renderTargetTexture.js +9 -0
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -1
- package/Materials/materialHelper.functions.js +12 -4
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.js +4 -3
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +7 -4
- package/Materials/uniformBuffer.js +37 -15
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.d.ts +1 -1
- package/Maths/math.vector.js +2 -2
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +25 -0
- package/Meshes/abstractMesh.hotSpot.js +37 -25
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Meshes/abstractMesh.js +4 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg2.js +6 -4
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/geometry.js +1 -1
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +1 -0
- package/Meshes/instancedMesh.js +3 -0
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/linesMesh.d.ts +5 -3
- package/Meshes/linesMesh.js +27 -8
- package/Meshes/linesMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +0 -19
- package/Meshes/mesh.js +2 -26
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +2 -2
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Misc/dumpTools.d.ts +1 -1
- package/Misc/dumpTools.js +23 -14
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/fileTools.js +8 -1
- package/Misc/fileTools.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +16 -7
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/lazy.d.ts +16 -0
- package/Misc/lazy.js +25 -0
- package/Misc/lazy.js.map +1 -0
- package/Misc/screenshotTools.js +1 -1
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/snapshotRenderingHelper.d.ts +6 -3
- package/Misc/snapshotRenderingHelper.js +37 -6
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +4 -0
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +17 -3
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +0 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +31 -0
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +67 -0
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +2 -2
- package/Particles/Node/Blocks/particleSourceTextureBlock.js +3 -3
- package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +3 -0
- package/Particles/Node/Blocks/systemBlock.js +3 -0
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +3 -1
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +2 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +118 -61
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.js +1 -0
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/particle.d.ts +8 -0
- package/Particles/particle.js +10 -0
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.d.ts +2 -4
- package/Particles/particleSystem.js +2 -4
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +6 -0
- package/Particles/thinParticleSystem.function.d.ts +2 -0
- package/Particles/thinParticleSystem.function.js +3 -0
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +15 -5
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +33 -3
- package/Rendering/objectRenderer.js +164 -38
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/clusteredLightingFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js +19 -0
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/helperFunctions.js +6 -1
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +33 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightUboDeclaration.js +5 -0
- package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js +2 -0
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +20 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.js +3 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.d.ts +7 -0
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +125 -0
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/Shaders/default.fragment.js +5 -0
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/default.vertex.js +6 -0
- package/Shaders/default.vertex.js.map +1 -1
- package/Shaders/lightProxy.fragment.d.ts +5 -0
- package/Shaders/lightProxy.fragment.js +13 -0
- package/Shaders/lightProxy.fragment.js.map +1 -0
- package/Shaders/lightProxy.vertex.d.ts +8 -0
- package/Shaders/lightProxy.vertex.js +19 -0
- package/Shaders/lightProxy.vertex.js.map +1 -0
- package/Shaders/pbr.fragment.d.ts +1 -0
- package/Shaders/pbr.fragment.js +4 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +6 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/clusteredLightingFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingFunctions.js +24 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightFragment.js +33 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +6 -0
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +22 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +3 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.d.ts +2 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +115 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +5 -0
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +6 -0
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/lightProxy.fragment.d.ts +5 -0
- package/ShadersWGSL/lightProxy.fragment.js +13 -0
- package/ShadersWGSL/lightProxy.fragment.js.map +1 -0
- package/ShadersWGSL/lightProxy.vertex.d.ts +7 -0
- package/ShadersWGSL/lightProxy.vertex.js +19 -0
- package/ShadersWGSL/lightProxy.vertex.js.map +1 -0
- package/ShadersWGSL/pbr.vertex.js +6 -0
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/Sprites/spriteManager.d.ts +5 -0
- package/Sprites/spriteManager.js +6 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.d.ts +5 -2
- package/Sprites/spriteRenderer.js.map +1 -1
- package/States/alphaCullingState.d.ts +3 -1
- package/States/alphaCullingState.js +39 -37
- package/States/alphaCullingState.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +28 -1
- package/scene.js +198 -34
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +2 -0
- package/sceneComponent.js +2 -0
- package/sceneComponent.js.map +1 -1
package/Meshes/abstractMesh.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { Scene, IDisposable } from "../scene.js";
|
|
|
5
5
|
import type { Vector2 } from "../Maths/math.vector.js";
|
|
6
6
|
import { Matrix, Vector3 } from "../Maths/math.vector.js";
|
|
7
7
|
import type { Node } from "../node.js";
|
|
8
|
+
import { VertexBuffer } from "../Buffers/buffer.js";
|
|
8
9
|
import type { IGetSetVerticesData } from "../Meshes/mesh.vertexData.js";
|
|
9
10
|
import { TransformNode } from "../Meshes/transformNode.js";
|
|
10
11
|
import type { SubMesh } from "../Meshes/subMesh.js";
|
|
@@ -137,6 +138,10 @@ declare class _InternalAbstractMeshDataInfo {
|
|
|
137
138
|
* if this is set to true, the mesh will be visible only if its parent(s) are also visible
|
|
138
139
|
*/
|
|
139
140
|
_inheritVisibility: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Used in frame graph mode only, to know which meshes to update when in frozen mode
|
|
143
|
+
*/
|
|
144
|
+
_wasActiveLastFrame: boolean;
|
|
140
145
|
}
|
|
141
146
|
/**
|
|
142
147
|
* Class used to store all common mesh properties
|
|
@@ -660,6 +665,26 @@ export declare abstract class AbstractMesh extends TransformNode implements IDis
|
|
|
660
665
|
abstract copyVerticesData(kind: string, vertexData: {
|
|
661
666
|
[kind: string]: Float32Array;
|
|
662
667
|
}): void;
|
|
668
|
+
/**
|
|
669
|
+
* Returns the mesh VertexBuffer object from the requested `kind`
|
|
670
|
+
* @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
|
|
671
|
+
* - VertexBuffer.PositionKind
|
|
672
|
+
* - VertexBuffer.NormalKind
|
|
673
|
+
* - VertexBuffer.UVKind
|
|
674
|
+
* - VertexBuffer.UV2Kind
|
|
675
|
+
* - VertexBuffer.UV3Kind
|
|
676
|
+
* - VertexBuffer.UV4Kind
|
|
677
|
+
* - VertexBuffer.UV5Kind
|
|
678
|
+
* - VertexBuffer.UV6Kind
|
|
679
|
+
* - VertexBuffer.ColorKind
|
|
680
|
+
* - VertexBuffer.MatricesIndicesKind
|
|
681
|
+
* - VertexBuffer.MatricesIndicesExtraKind
|
|
682
|
+
* - VertexBuffer.MatricesWeightsKind
|
|
683
|
+
* - VertexBuffer.MatricesWeightsExtraKind
|
|
684
|
+
* @param bypassInstanceData defines a boolean indicating that the function should not take into account the instance data (applies only if the mesh has instances). Default: false
|
|
685
|
+
* @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
|
|
686
|
+
*/
|
|
687
|
+
abstract getVertexBuffer(kind: string, bypassInstanceData?: boolean): Nullable<VertexBuffer>;
|
|
663
688
|
/**
|
|
664
689
|
* Sets the vertex data of the mesh geometry for the requested `kind`.
|
|
665
690
|
* If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Vector3, TmpVectors, Matrix } from "../Maths/math.vector.js";
|
|
2
2
|
import { VertexBuffer } from "../Buffers/buffer.js";
|
|
3
3
|
|
|
4
|
+
import { EnumerateFloatValues } from "../Buffers/bufferUtils.js";
|
|
4
5
|
/**
|
|
5
6
|
* Create a HotSpotQuery from a picking info
|
|
6
7
|
* @remarks If there is no pickedMesh or the pickedMesh has no indices, the faceId is used as the base index
|
|
@@ -15,6 +16,21 @@ export function CreateHotSpotQueryForPickingInfo(pickingInfo) {
|
|
|
15
16
|
barycentric: [pickingInfo.bu, pickingInfo.bv, 1 - pickingInfo.bu - pickingInfo.bv],
|
|
16
17
|
};
|
|
17
18
|
}
|
|
19
|
+
function GetVertexElementData(mesh, index, kind) {
|
|
20
|
+
const vertexBuffer = mesh.getVertexBuffer(kind);
|
|
21
|
+
if (!vertexBuffer) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const bufferData = vertexBuffer.getData();
|
|
25
|
+
if (!bufferData) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
// EnumerateFloatValues synchronously calls the callback, hence the non-null assertion.
|
|
29
|
+
let values;
|
|
30
|
+
EnumerateFloatValues(bufferData, vertexBuffer.byteStride * index, vertexBuffer.byteStride, vertexBuffer.getSize(), vertexBuffer.type, 1, // Request only a single element.
|
|
31
|
+
vertexBuffer.normalized, (v) => (values = v));
|
|
32
|
+
return values;
|
|
33
|
+
}
|
|
18
34
|
/**
|
|
19
35
|
* Return a transformed local position from a mesh and vertex index
|
|
20
36
|
* @param mesh mesh used to get vertex array from
|
|
@@ -23,63 +39,59 @@ export function CreateHotSpotQueryForPickingInfo(pickingInfo) {
|
|
|
23
39
|
* @returns false if it was not possible to compute the position for that vertex
|
|
24
40
|
*/
|
|
25
41
|
export function GetTransformedPosition(mesh, index, res) {
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
42
|
+
const positions = GetVertexElementData(mesh, index, VertexBuffer.PositionKind);
|
|
43
|
+
if (!positions) {
|
|
28
44
|
return false;
|
|
29
45
|
}
|
|
30
|
-
|
|
31
|
-
const values = [data[base + 0], data[base + 1], data[base + 2]];
|
|
32
|
-
if (values.some((value) => isNaN(value ?? Number.NaN))) {
|
|
46
|
+
if (positions.some((value) => isNaN(value ?? Number.NaN))) {
|
|
33
47
|
return false;
|
|
34
48
|
}
|
|
35
49
|
if (mesh.morphTargetManager) {
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
const base = index * 3;
|
|
51
|
+
for (let i = 0; i < positions.length; i++) {
|
|
52
|
+
let value = positions[i];
|
|
38
53
|
for (let targetCount = 0; targetCount < mesh.morphTargetManager.numTargets; targetCount++) {
|
|
39
54
|
const target = mesh.morphTargetManager.getTarget(targetCount);
|
|
40
55
|
const influence = target.influence;
|
|
41
56
|
if (influence !== 0) {
|
|
42
57
|
const targetData = target.getPositions();
|
|
43
58
|
if (targetData) {
|
|
44
|
-
value += (targetData[base +
|
|
59
|
+
value += (targetData[base + i] - positions[i]) * influence;
|
|
45
60
|
}
|
|
46
61
|
}
|
|
47
62
|
}
|
|
48
|
-
|
|
63
|
+
positions[i] = value;
|
|
49
64
|
}
|
|
50
65
|
}
|
|
51
|
-
res.fromArray(
|
|
66
|
+
res.fromArray(positions);
|
|
52
67
|
if (mesh.skeleton) {
|
|
53
|
-
const matricesIndicesData = mesh
|
|
54
|
-
const matricesWeightsData = mesh
|
|
55
|
-
if (
|
|
68
|
+
const matricesIndicesData = GetVertexElementData(mesh, index, VertexBuffer.MatricesIndicesKind);
|
|
69
|
+
const matricesWeightsData = GetVertexElementData(mesh, index, VertexBuffer.MatricesWeightsKind);
|
|
70
|
+
if (matricesIndicesData && matricesWeightsData) {
|
|
56
71
|
const needExtras = mesh.numBoneInfluencers > 4;
|
|
57
|
-
const matricesIndicesExtraData = needExtras ? mesh
|
|
58
|
-
const matricesWeightsExtraData = needExtras ? mesh
|
|
72
|
+
const matricesIndicesExtraData = needExtras ? GetVertexElementData(mesh, index, VertexBuffer.MatricesIndicesExtraKind) : null;
|
|
73
|
+
const matricesWeightsExtraData = needExtras ? GetVertexElementData(mesh, index, VertexBuffer.MatricesWeightsExtraKind) : null;
|
|
59
74
|
const skeletonMatrices = mesh.skeleton.getTransformMatrices(mesh);
|
|
60
75
|
const finalMatrix = TmpVectors.Matrix[0];
|
|
61
76
|
const tempMatrix = TmpVectors.Matrix[1];
|
|
62
77
|
finalMatrix.reset();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
let weight;
|
|
66
|
-
for (inf = 0; inf < 4; inf++) {
|
|
67
|
-
weight = matricesWeightsData[matWeightIdx + inf];
|
|
78
|
+
for (let i = 0; i < matricesWeightsData.length; i++) {
|
|
79
|
+
const weight = matricesWeightsData[i];
|
|
68
80
|
if (weight > 0) {
|
|
69
|
-
Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[
|
|
81
|
+
Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[i] * 16), weight, tempMatrix);
|
|
70
82
|
finalMatrix.addToSelf(tempMatrix);
|
|
71
83
|
}
|
|
72
84
|
}
|
|
73
85
|
if (matricesIndicesExtraData && matricesWeightsExtraData) {
|
|
74
|
-
for (
|
|
75
|
-
weight = matricesWeightsExtraData[
|
|
86
|
+
for (let i = 0; i < matricesWeightsExtraData.length; i++) {
|
|
87
|
+
const weight = matricesWeightsExtraData[i];
|
|
76
88
|
if (weight > 0) {
|
|
77
|
-
Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[
|
|
89
|
+
Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[i] * 16), weight, tempMatrix);
|
|
78
90
|
finalMatrix.addToSelf(tempMatrix);
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
93
|
}
|
|
82
|
-
Vector3.TransformCoordinatesFromFloatsToRef(
|
|
94
|
+
Vector3.TransformCoordinatesFromFloatsToRef(positions[0], positions[1], positions[2], finalMatrix, res);
|
|
83
95
|
}
|
|
84
96
|
}
|
|
85
97
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstractMesh.hotSpot.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/abstractMesh.hotSpot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAgBnD;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAwB;IACrE,MAAM,OAAO,GAAG,WAAW,CAAC,UAAU,EAAE,UAAU,EAAE,CAAC;IACrD,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC;IAEpC,OAAO;QACH,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,CAA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C;QAC1B,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACjC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1B,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;QACjC,QAAQ,CAAC,SAAS,EAAE,CAAC;QACrB,QAAQ,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;QAElD,2CAA2C;QAC3C,MAAM,UAAU,GACZ,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,QAAQ,CAAC,eAAe;gBACzB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC,CAAC,SAAS,CAAC,wCAAwC,CAAC,CAAC;QAElJ,IAAI,UAAU,EAAE,CAAC;YACb,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QAED,oCAAoC;QACpC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,CAAC,CAAC;QAC1E,SAAS,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import type { AbstractMesh, PickingInfo } from \"core/index\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\n/**\r\n * Data for mesh hotspot computation\r\n */\r\nexport type HotSpotQuery = {\r\n /**\r\n * 3 point indices\r\n */\r\n pointIndex: [number, number, number];\r\n /**\r\n * 3 barycentric coordinates\r\n */\r\n barycentric: [number, number, number];\r\n};\r\n\r\n/**\r\n * Create a HotSpotQuery from a picking info\r\n * @remarks If there is no pickedMesh or the pickedMesh has no indices, the faceId is used as the base index\r\n * @param pickingInfo picking info to use\r\n * @returns the created HotSpotQuery\r\n */\r\nexport function CreateHotSpotQueryForPickingInfo(pickingInfo: PickingInfo): HotSpotQuery {\r\n const indices = pickingInfo.pickedMesh?.getIndices();\r\n const base = pickingInfo.faceId * 3;\r\n\r\n return {\r\n pointIndex: indices ? [indices[base], indices[base + 1], indices[base + 2]] : [base, base + 1, base + 2],\r\n barycentric: [pickingInfo.bu, pickingInfo.bv, 1 - pickingInfo.bu - pickingInfo.bv],\r\n };\r\n}\r\n\r\n/**\r\n * Return a transformed local position from a mesh and vertex index\r\n * @param mesh mesh used to get vertex array from\r\n * @param index vertex index\r\n * @param res resulting local position\r\n * @returns false if it was not possible to compute the position for that vertex\r\n */\r\nexport function GetTransformedPosition(mesh: AbstractMesh, index: number, res: Vector3): boolean {\r\n const data = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n if (!data) {\r\n return false;\r\n }\r\n const base = index * 3;\r\n const values = [data[base + 0], data[base + 1], data[base + 2]];\r\n if (values.some((value) => isNaN(value ?? Number.NaN))) {\r\n return false;\r\n }\r\n\r\n if (mesh.morphTargetManager) {\r\n for (let component = 0; component < 3; component++) {\r\n let value = values[component];\r\n for (let targetCount = 0; targetCount < mesh.morphTargetManager.numTargets; targetCount++) {\r\n const target = mesh.morphTargetManager.getTarget(targetCount);\r\n const influence = target.influence;\r\n if (influence !== 0) {\r\n const targetData = target.getPositions();\r\n if (targetData) {\r\n value += (targetData[base + component] - data[base + component]) * influence;\r\n }\r\n }\r\n }\r\n values[component] = value;\r\n }\r\n }\r\n res.fromArray(values);\r\n if (mesh.skeleton) {\r\n const matricesIndicesData = mesh.getVerticesData(VertexBuffer.MatricesIndicesKind);\r\n const matricesWeightsData = mesh.getVerticesData(VertexBuffer.MatricesWeightsKind);\r\n if (matricesWeightsData && matricesIndicesData) {\r\n const needExtras = mesh.numBoneInfluencers > 4;\r\n const matricesIndicesExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesIndicesExtraKind) : null;\r\n const matricesWeightsExtraData = needExtras ? mesh.getVerticesData(VertexBuffer.MatricesWeightsExtraKind) : null;\r\n const skeletonMatrices = mesh.skeleton.getTransformMatrices(mesh);\r\n\r\n const finalMatrix = TmpVectors.Matrix[0];\r\n const tempMatrix = TmpVectors.Matrix[1];\r\n\r\n finalMatrix.reset();\r\n const matWeightIdx = index * 4;\r\n\r\n let inf: number;\r\n let weight: number;\r\n for (inf = 0; inf < 4; inf++) {\r\n weight = matricesWeightsData[matWeightIdx + inf];\r\n if (weight > 0) {\r\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);\r\n finalMatrix.addToSelf(tempMatrix);\r\n }\r\n }\r\n if (matricesIndicesExtraData && matricesWeightsExtraData) {\r\n for (inf = 0; inf < 4; inf++) {\r\n weight = matricesWeightsExtraData[matWeightIdx + inf];\r\n if (weight > 0) {\r\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);\r\n finalMatrix.addToSelf(tempMatrix);\r\n }\r\n }\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(values[0], values[1], values[2], finalMatrix, res);\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Compute a world space hotspot position\r\n * TmpVectors.Vector3[0..4] are modified by this function. Do not use them as result output.\r\n * @param mesh mesh used to get hotspot from\r\n * @param hotSpotQuery point indices and barycentric\r\n * @param resPosition output world position\r\n * @param resNormal optional output world normal\r\n * @returns false if it was not possible to compute the hotspot position\r\n */\r\nexport function GetHotSpotToRef(mesh: AbstractMesh, hotSpotQuery: HotSpotQuery, resPosition: Vector3, resNormal?: Vector3): boolean {\r\n resPosition.set(0, 0, 0);\r\n for (let i = 0; i < 3; i++) {\r\n const index = hotSpotQuery.pointIndex[i];\r\n if (!GetTransformedPosition(mesh, index, TmpVectors.Vector3[i])) {\r\n return false;\r\n }\r\n TmpVectors.Vector3[i].scaleAndAddToRef(hotSpotQuery.barycentric[i], resPosition);\r\n }\r\n\r\n // Convert the result to world space\r\n Vector3.TransformCoordinatesToRef(resPosition, mesh.getWorldMatrix(), resPosition);\r\n\r\n // compute normal in world space\r\n if (resNormal) {\r\n const pointA = TmpVectors.Vector3[0];\r\n const pointB = TmpVectors.Vector3[1];\r\n const pointC = TmpVectors.Vector3[2];\r\n const segmentA = TmpVectors.Vector3[3];\r\n const segmentB = TmpVectors.Vector3[4];\r\n segmentA.copyFrom(pointB);\r\n segmentA.subtractInPlace(pointA);\r\n segmentB.copyFrom(pointC);\r\n segmentB.subtractInPlace(pointA);\r\n segmentA.normalize();\r\n segmentB.normalize();\r\n Vector3.CrossToRef(segmentA, segmentB, resNormal);\r\n\r\n // flip normal when face culling is changed\r\n const flipNormal =\r\n mesh.material &&\r\n mesh.material.sideOrientation ===\r\n (mesh.getScene().useRightHandedSystem ? Constants.MATERIAL_ClockWiseSideOrientation : Constants.MATERIAL_CounterClockWiseSideOrientation);\r\n\r\n if (flipNormal) {\r\n resNormal.scaleInPlace(-1);\r\n }\r\n\r\n // Convert the result to world space\r\n Vector3.TransformNormalToRef(resNormal, mesh.getWorldMatrix(), resNormal);\r\n resNormal.normalize();\r\n }\r\n\r\n return true;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"abstractMesh.hotSpot.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/abstractMesh.hotSpot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,gCAA+B;AACnD,OAAO,EAAE,oBAAoB,EAAE,kCAAiC;AAgBhE;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAAC,WAAwB;IACrE,MAAM,OAAO,GAAG,WAAW,C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AS,CAAC,wCAAwC,CAAC,CAAC;QAElJ,IAAI,UAAU,EAAE,CAAC;YACb,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QAED,oCAAoC;QACpC,OAAO,CAAC,oBAAoB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,EAAE,SAAS,CAAC,CAAC;QAC1E,SAAS,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import type { AbstractMesh, PickingInfo } from \"core/index\";\r\nimport { Vector3, TmpVectors, Matrix } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { EnumerateFloatValues } from \"core/Buffers/bufferUtils\";\r\n\r\n/**\r\n * Data for mesh hotspot computation\r\n */\r\nexport type HotSpotQuery = {\r\n /**\r\n * 3 point indices\r\n */\r\n pointIndex: [number, number, number];\r\n /**\r\n * 3 barycentric coordinates\r\n */\r\n barycentric: [number, number, number];\r\n};\r\n\r\n/**\r\n * Create a HotSpotQuery from a picking info\r\n * @remarks If there is no pickedMesh or the pickedMesh has no indices, the faceId is used as the base index\r\n * @param pickingInfo picking info to use\r\n * @returns the created HotSpotQuery\r\n */\r\nexport function CreateHotSpotQueryForPickingInfo(pickingInfo: PickingInfo): HotSpotQuery {\r\n const indices = pickingInfo.pickedMesh?.getIndices();\r\n const base = pickingInfo.faceId * 3;\r\n\r\n return {\r\n pointIndex: indices ? [indices[base], indices[base + 1], indices[base + 2]] : [base, base + 1, base + 2],\r\n barycentric: [pickingInfo.bu, pickingInfo.bv, 1 - pickingInfo.bu - pickingInfo.bv],\r\n };\r\n}\r\n\r\nfunction GetVertexElementData(mesh: AbstractMesh, index: number, kind: string) {\r\n const vertexBuffer = mesh.getVertexBuffer(kind);\r\n if (!vertexBuffer) {\r\n return null;\r\n }\r\n\r\n const bufferData = vertexBuffer.getData();\r\n if (!bufferData) {\r\n return null;\r\n }\r\n\r\n // EnumerateFloatValues synchronously calls the callback, hence the non-null assertion.\r\n let values!: number[];\r\n EnumerateFloatValues(\r\n bufferData,\r\n vertexBuffer.byteStride * index,\r\n vertexBuffer.byteStride,\r\n vertexBuffer.getSize(),\r\n vertexBuffer.type,\r\n 1, // Request only a single element.\r\n vertexBuffer.normalized,\r\n (v) => (values = v)\r\n );\r\n\r\n return values;\r\n}\r\n\r\n/**\r\n * Return a transformed local position from a mesh and vertex index\r\n * @param mesh mesh used to get vertex array from\r\n * @param index vertex index\r\n * @param res resulting local position\r\n * @returns false if it was not possible to compute the position for that vertex\r\n */\r\nexport function GetTransformedPosition(mesh: AbstractMesh, index: number, res: Vector3): boolean {\r\n const positions = GetVertexElementData(mesh, index, VertexBuffer.PositionKind);\r\n if (!positions) {\r\n return false;\r\n }\r\n\r\n if (positions.some((value) => isNaN(value ?? Number.NaN))) {\r\n return false;\r\n }\r\n\r\n if (mesh.morphTargetManager) {\r\n const base = index * 3;\r\n for (let i = 0; i < positions.length; i++) {\r\n let value = positions[i];\r\n for (let targetCount = 0; targetCount < mesh.morphTargetManager.numTargets; targetCount++) {\r\n const target = mesh.morphTargetManager.getTarget(targetCount);\r\n const influence = target.influence;\r\n if (influence !== 0) {\r\n const targetData = target.getPositions();\r\n if (targetData) {\r\n value += (targetData[base + i] - positions[i]) * influence;\r\n }\r\n }\r\n }\r\n positions[i] = value;\r\n }\r\n }\r\n\r\n res.fromArray(positions);\r\n\r\n if (mesh.skeleton) {\r\n const matricesIndicesData = GetVertexElementData(mesh, index, VertexBuffer.MatricesIndicesKind);\r\n const matricesWeightsData = GetVertexElementData(mesh, index, VertexBuffer.MatricesWeightsKind);\r\n if (matricesIndicesData && matricesWeightsData) {\r\n const needExtras = mesh.numBoneInfluencers > 4;\r\n const matricesIndicesExtraData = needExtras ? GetVertexElementData(mesh, index, VertexBuffer.MatricesIndicesExtraKind) : null;\r\n const matricesWeightsExtraData = needExtras ? GetVertexElementData(mesh, index, VertexBuffer.MatricesWeightsExtraKind) : null;\r\n const skeletonMatrices = mesh.skeleton.getTransformMatrices(mesh);\r\n\r\n const finalMatrix = TmpVectors.Matrix[0];\r\n const tempMatrix = TmpVectors.Matrix[1];\r\n\r\n finalMatrix.reset();\r\n\r\n for (let i = 0; i < matricesWeightsData.length; i++) {\r\n const weight = matricesWeightsData[i];\r\n if (weight > 0) {\r\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[i] * 16), weight, tempMatrix);\r\n finalMatrix.addToSelf(tempMatrix);\r\n }\r\n }\r\n if (matricesIndicesExtraData && matricesWeightsExtraData) {\r\n for (let i = 0; i < matricesWeightsExtraData.length; i++) {\r\n const weight = matricesWeightsExtraData[i];\r\n if (weight > 0) {\r\n Matrix.FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[i] * 16), weight, tempMatrix);\r\n finalMatrix.addToSelf(tempMatrix);\r\n }\r\n }\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(positions[0], positions[1], positions[2], finalMatrix, res);\r\n }\r\n }\r\n\r\n return true;\r\n}\r\n\r\n/**\r\n * Compute a world space hotspot position\r\n * TmpVectors.Vector3[0..4] are modified by this function. Do not use them as result output.\r\n * @param mesh mesh used to get hotspot from\r\n * @param hotSpotQuery point indices and barycentric\r\n * @param resPosition output world position\r\n * @param resNormal optional output world normal\r\n * @returns false if it was not possible to compute the hotspot position\r\n */\r\nexport function GetHotSpotToRef(mesh: AbstractMesh, hotSpotQuery: HotSpotQuery, resPosition: Vector3, resNormal?: Vector3): boolean {\r\n resPosition.set(0, 0, 0);\r\n for (let i = 0; i < 3; i++) {\r\n const index = hotSpotQuery.pointIndex[i];\r\n if (!GetTransformedPosition(mesh, index, TmpVectors.Vector3[i])) {\r\n return false;\r\n }\r\n TmpVectors.Vector3[i].scaleAndAddToRef(hotSpotQuery.barycentric[i], resPosition);\r\n }\r\n\r\n // Convert the result to world space\r\n Vector3.TransformCoordinatesToRef(resPosition, mesh.getWorldMatrix(), resPosition);\r\n\r\n // compute normal in world space\r\n if (resNormal) {\r\n const pointA = TmpVectors.Vector3[0];\r\n const pointB = TmpVectors.Vector3[1];\r\n const pointC = TmpVectors.Vector3[2];\r\n const segmentA = TmpVectors.Vector3[3];\r\n const segmentB = TmpVectors.Vector3[4];\r\n segmentA.copyFrom(pointB);\r\n segmentA.subtractInPlace(pointA);\r\n segmentB.copyFrom(pointC);\r\n segmentB.subtractInPlace(pointA);\r\n segmentA.normalize();\r\n segmentB.normalize();\r\n Vector3.CrossToRef(segmentA, segmentB, resNormal);\r\n\r\n // flip normal when face culling is changed\r\n const flipNormal =\r\n mesh.material &&\r\n mesh.material.sideOrientation ===\r\n (mesh.getScene().useRightHandedSystem ? Constants.MATERIAL_ClockWiseSideOrientation : Constants.MATERIAL_CounterClockWiseSideOrientation);\r\n\r\n if (flipNormal) {\r\n resNormal.scaleInPlace(-1);\r\n }\r\n\r\n // Convert the result to world space\r\n Vector3.TransformNormalToRef(resNormal, mesh.getWorldMatrix(), resNormal);\r\n resNormal.normalize();\r\n }\r\n\r\n return true;\r\n}\r\n"]}
|
package/Meshes/abstractMesh.js
CHANGED
|
@@ -156,6 +156,10 @@ class _InternalAbstractMeshDataInfo {
|
|
|
156
156
|
* if this is set to true, the mesh will be visible only if its parent(s) are also visible
|
|
157
157
|
*/
|
|
158
158
|
this._inheritVisibility = false;
|
|
159
|
+
/**
|
|
160
|
+
* Used in frame graph mode only, to know which meshes to update when in frozen mode
|
|
161
|
+
*/
|
|
162
|
+
this._wasActiveLastFrame = false;
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
165
|
/**
|