rhodonite 0.20.2 → 0.22.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/README.md +10 -2
- package/VERSION-FILE +1 -1
- package/dist/esm/foundation/components/Camera/CameraComponent.d.ts +15 -0
- package/dist/esm/foundation/components/Light/LightComponent.d.ts +109 -4
- package/dist/esm/foundation/components/Physics/PhysicsComponent.d.ts +1 -1
- package/dist/esm/foundation/core/Component.d.ts +1 -8
- package/dist/esm/foundation/core/Config.d.ts +165 -6
- package/dist/esm/foundation/core/GlobalDataRepository.d.ts +12 -8
- package/dist/esm/foundation/core/MemoryManager.d.ts +12 -0
- package/dist/esm/foundation/definitions/ProcessApproach.d.ts +1 -6
- package/dist/esm/foundation/definitions/ShaderSemantics.d.ts +0 -1
- package/dist/esm/foundation/helpers/Shadow/PointShadowMap.d.ts +3 -1
- package/dist/esm/foundation/helpers/Shadow/ShadowSystem.d.ts +13 -0
- package/dist/esm/foundation/materials/contents/CustomMaterialContent.d.ts +1 -1
- package/dist/esm/foundation/materials/core/AbstractMaterialContent.d.ts +1 -23
- package/dist/esm/foundation/materials/core/Material.d.ts +10 -14
- package/dist/esm/foundation/materials/core/MaterialRepository.d.ts +5 -0
- package/dist/esm/foundation/physics/PhysicsProperty.d.ts +9 -2
- package/dist/esm/foundation/physics/index.d.ts +0 -1
- package/dist/esm/foundation/renderer/index.d.ts +1 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterBuilder.d.ts +97 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterLayout.d.ts +98 -0
- package/dist/esm/foundation/renderer/lightCluster/LightClusterSystem.d.ts +171 -0
- package/dist/esm/foundation/renderer/lightCluster/index.d.ts +1 -0
- package/dist/esm/foundation/system/Engine.d.ts +9 -2
- package/dist/esm/foundation/system/EngineState.d.ts +1 -1
- package/dist/esm/foundation/textures/TextureArray.d.ts +1 -1
- package/dist/esm/index.js +1181 -824
- package/dist/esm/webgl/MultiDraw.d.ts +1 -1
- package/dist/esm/webgl/WebGLResourceRepository.d.ts +1 -2
- package/dist/{esmdev/webgl/WebGLStrategyDataTexture.d.ts → esm/webgl/WebGLStrategyWebGL2.d.ts} +20 -4
- package/dist/esm/webgl/debug/BufferLayoutDecoder.d.ts +83 -0
- package/dist/esm/webgl/debug/ShaderParameterDebugger.d.ts +47 -0
- package/dist/esm/webgl/debug/index.d.ts +3 -0
- package/dist/esm/webgl/debug/types.d.ts +114 -0
- package/dist/esm/webgl/index.d.ts +2 -2
- package/dist/esm/webgl/main.d.ts +2 -4
- package/dist/esm/webgl/shaders/StandardShaderPart.d.ts +1 -1
- package/dist/esm/webgl/types/CommonTypes.d.ts +0 -1
- package/dist/esm/webgpu/WebGpuLightClusterBuilder.d.ts +34 -0
- package/dist/esm/webgpu/WebGpuResourceRepository.d.ts +28 -3
- package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +18 -1
- package/dist/esmdev/foundation/components/Camera/CameraComponent.d.ts +15 -0
- package/dist/esmdev/foundation/components/Light/LightComponent.d.ts +109 -4
- package/dist/esmdev/foundation/components/Physics/PhysicsComponent.d.ts +1 -1
- package/dist/esmdev/foundation/core/Component.d.ts +1 -8
- package/dist/esmdev/foundation/core/Config.d.ts +165 -6
- package/dist/esmdev/foundation/core/GlobalDataRepository.d.ts +12 -8
- package/dist/esmdev/foundation/core/MemoryManager.d.ts +12 -0
- package/dist/esmdev/foundation/definitions/ProcessApproach.d.ts +1 -6
- package/dist/esmdev/foundation/definitions/ShaderSemantics.d.ts +0 -1
- package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.d.ts +3 -1
- package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.d.ts +13 -0
- package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.d.ts +1 -1
- package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.d.ts +1 -23
- package/dist/esmdev/foundation/materials/core/Material.d.ts +10 -14
- package/dist/esmdev/foundation/materials/core/MaterialRepository.d.ts +5 -0
- package/dist/esmdev/foundation/physics/PhysicsProperty.d.ts +9 -2
- package/dist/esmdev/foundation/physics/index.d.ts +0 -1
- package/dist/esmdev/foundation/renderer/index.d.ts +1 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterBuilder.d.ts +97 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterLayout.d.ts +98 -0
- package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.d.ts +171 -0
- package/dist/esmdev/foundation/renderer/lightCluster/index.d.ts +1 -0
- package/dist/esmdev/foundation/system/Engine.d.ts +9 -2
- package/dist/esmdev/foundation/system/EngineState.d.ts +1 -1
- package/dist/esmdev/foundation/textures/TextureArray.d.ts +1 -1
- package/dist/esmdev/index.js +3419 -2172
- package/dist/esmdev/webgl/MultiDraw.d.ts +1 -1
- package/dist/esmdev/webgl/WebGLResourceRepository.d.ts +1 -2
- package/dist/{esm/webgl/WebGLStrategyDataTexture.d.ts → esmdev/webgl/WebGLStrategyWebGL2.d.ts} +20 -4
- package/dist/esmdev/webgl/debug/BufferLayoutDecoder.d.ts +83 -0
- package/dist/esmdev/webgl/debug/ShaderParameterDebugger.d.ts +47 -0
- package/dist/esmdev/webgl/debug/index.d.ts +3 -0
- package/dist/esmdev/webgl/debug/types.d.ts +114 -0
- package/dist/esmdev/webgl/index.d.ts +2 -2
- package/dist/esmdev/webgl/main.d.ts +2 -4
- package/dist/esmdev/webgl/shaders/StandardShaderPart.d.ts +1 -1
- package/dist/esmdev/webgl/types/CommonTypes.d.ts +0 -1
- package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.d.ts +34 -0
- package/dist/esmdev/webgpu/WebGpuResourceRepository.d.ts +28 -3
- package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +18 -1
- package/package.json +2 -1
- package/dist/esm/foundation/physics/Oimo/OimoPhysicsStrategy.d.ts +0 -124
- package/dist/esm/foundation/physics/Oimo/index.d.ts +0 -1
- package/dist/esm/webgl/WebGLStrategyUniform.d.ts +0 -193
- package/dist/esmdev/foundation/physics/Oimo/OimoPhysicsStrategy.d.ts +0 -124
- package/dist/esmdev/foundation/physics/Oimo/index.d.ts +0 -1
- package/dist/esmdev/webgl/WebGLStrategyUniform.d.ts +0 -193
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { Config } from '../../core/Config';
|
|
2
|
-
import type { ShapeInstance } from '../../geometry/Shape';
|
|
3
|
-
import type { ISceneGraphEntity } from '../../helpers';
|
|
4
|
-
import { type IVector3 } from '../../math';
|
|
5
|
-
import type { PhysicsBodyProperty, PhysicsColliderProperty, PhysicsMotionProperty, PhysicsPropertyInner } from '../PhysicsProperty';
|
|
6
|
-
import type { PhysicsStrategy } from '../PhysicsStrategy';
|
|
7
|
-
import type { PhysicsWorldProperty } from '../PhysicsWorldProperty';
|
|
8
|
-
/**
|
|
9
|
-
* Physics strategy implementation using the Oimo.js physics engine.
|
|
10
|
-
* This class provides physics simulation capabilities for 3D objects in the scene.
|
|
11
|
-
* It implements the PhysicsStrategy interface to integrate with the Rhodonite framework.
|
|
12
|
-
*/
|
|
13
|
-
export declare class OimoPhysicsStrategy implements PhysicsStrategy {
|
|
14
|
-
/**
|
|
15
|
-
* Global physics world properties shared across all instances.
|
|
16
|
-
* Contains gravity settings and randomization options.
|
|
17
|
-
*/
|
|
18
|
-
static __worldProperty: PhysicsWorldProperty;
|
|
19
|
-
/**
|
|
20
|
-
* The shared Oimo physics world instance.
|
|
21
|
-
* All physics bodies are added to this single world for simulation.
|
|
22
|
-
*/
|
|
23
|
-
static __world: any;
|
|
24
|
-
/**
|
|
25
|
-
* The Oimo physics body associated with this strategy instance.
|
|
26
|
-
*/
|
|
27
|
-
private __body;
|
|
28
|
-
/**
|
|
29
|
-
* The scene graph entity that this physics strategy is attached to.
|
|
30
|
-
*/
|
|
31
|
-
private __entity?;
|
|
32
|
-
/**
|
|
33
|
-
* Cached physics properties used for body recreation when needed.
|
|
34
|
-
*/
|
|
35
|
-
private __property;
|
|
36
|
-
/**
|
|
37
|
-
* The original local scale of the physics shape before any transformations.
|
|
38
|
-
*/
|
|
39
|
-
private __localScale;
|
|
40
|
-
private __shapeLocalPosition;
|
|
41
|
-
private __shapeLocalRotation;
|
|
42
|
-
private __resolvedShapeLocalRotation;
|
|
43
|
-
private __worldScale;
|
|
44
|
-
private __worldSignedScale;
|
|
45
|
-
private __usesShapeInstance;
|
|
46
|
-
private __shapeType?;
|
|
47
|
-
private __warnedScaleApproximation;
|
|
48
|
-
/** Reusable quaternion for world-rotation lookups (avoids per-frame allocations) */
|
|
49
|
-
private __tmpWorldRotation;
|
|
50
|
-
/** Reusable Euler angles for rotation conversions (avoids per-frame allocations) */
|
|
51
|
-
private __tmpEuler;
|
|
52
|
-
/** Reusable temporaries for body pose calculation (avoids per-frame allocations) */
|
|
53
|
-
private __tmpShapeScaledOffset;
|
|
54
|
-
private __tmpBodyWorldOffset;
|
|
55
|
-
private __tmpBodyPose;
|
|
56
|
-
/** Reusable temporaries for the per-frame physics sync */
|
|
57
|
-
private __tmpBodyRotation;
|
|
58
|
-
private __tmpEntityRotation;
|
|
59
|
-
private __tmpInverseLocalRotation;
|
|
60
|
-
private __tmpUpdatePosition;
|
|
61
|
-
/**
|
|
62
|
-
* Creates a new OimoPhysicsStrategy instance.
|
|
63
|
-
* Initializes the shared Oimo physics world if it doesn't exist yet.
|
|
64
|
-
*/
|
|
65
|
-
constructor();
|
|
66
|
-
/**
|
|
67
|
-
* Sets up the physics shape for the given entity with specified properties.
|
|
68
|
-
* Creates a physics body in the Oimo world with the provided configuration.
|
|
69
|
-
*
|
|
70
|
-
* @param prop - The physics properties defining the shape, size, position, and material properties
|
|
71
|
-
* @param entity - The scene graph entity to associate with this physics body
|
|
72
|
-
*/
|
|
73
|
-
setShape(prop: PhysicsPropertyInner, entity: ISceneGraphEntity): void;
|
|
74
|
-
setShapeInstance(shape: ShapeInstance, body: PhysicsBodyProperty, collider: PhysicsColliderProperty, entity: ISceneGraphEntity, worldScale?: IVector3, motion?: PhysicsMotionProperty): void;
|
|
75
|
-
clearShapeInstances(): void;
|
|
76
|
-
/**
|
|
77
|
-
* Updates the associated entity's transform based on the physics body's current state.
|
|
78
|
-
* This method should be called each frame to synchronize the visual representation
|
|
79
|
-
* with the physics simulation results.
|
|
80
|
-
*/
|
|
81
|
-
update(_config: Config): void;
|
|
82
|
-
/**
|
|
83
|
-
* Sets the world position of the physics body.
|
|
84
|
-
* Recreates the physics body with the new position while preserving other properties.
|
|
85
|
-
*
|
|
86
|
-
* @param worldPosition - The new world position to set for the physics body
|
|
87
|
-
*/
|
|
88
|
-
setPosition(worldPosition: IVector3): void;
|
|
89
|
-
/**
|
|
90
|
-
* Sets the rotation of the physics body using Euler angles.
|
|
91
|
-
* Recreates the physics body with the new rotation while preserving other properties.
|
|
92
|
-
*
|
|
93
|
-
* @param eulerAngles - The new Euler angles (in radians) to set for the physics body
|
|
94
|
-
*/
|
|
95
|
-
setEulerAngle(eulerAngles: IVector3): void;
|
|
96
|
-
/**
|
|
97
|
-
* Sets the scale of the physics body.
|
|
98
|
-
* Recreates the physics body with the new scale applied to the original local scale
|
|
99
|
-
* while preserving other properties.
|
|
100
|
-
*
|
|
101
|
-
* @param scale - The scale factors to apply to the physics body's dimensions
|
|
102
|
-
*/
|
|
103
|
-
setScale(scale: IVector3): void;
|
|
104
|
-
private __canCreateBody;
|
|
105
|
-
private __removeBody;
|
|
106
|
-
private __resolveScaledShape;
|
|
107
|
-
private __createLegacyScaledSize;
|
|
108
|
-
private __toBodyPose;
|
|
109
|
-
/**
|
|
110
|
-
* Fills the reusable body pose with the given position and rotation.
|
|
111
|
-
* Accepts plain `{ x, y, z }` objects as well as vector/quaternion instances
|
|
112
|
-
* (Oimo.js returns plain objects from its body getters).
|
|
113
|
-
* @param position - The body position to copy
|
|
114
|
-
* @param rotation - The body rotation to copy
|
|
115
|
-
* @returns The reusable body pose
|
|
116
|
-
*/
|
|
117
|
-
private __reuseBodyPose;
|
|
118
|
-
/**
|
|
119
|
-
* Advances the physics simulation by one time step.
|
|
120
|
-
* This static method should be called once per frame to update all physics bodies
|
|
121
|
-
* in the shared world. It processes collisions, applies forces, and updates positions.
|
|
122
|
-
*/
|
|
123
|
-
static update(): void;
|
|
124
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './OimoPhysicsStrategy';
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import type { MeshComponent } from '../foundation/components/Mesh/MeshComponent';
|
|
2
|
-
import type { Mesh } from '../foundation/geometry/Mesh';
|
|
3
|
-
import { Primitive } from '../foundation/geometry/Primitive';
|
|
4
|
-
import type { Material } from '../foundation/materials/core/Material';
|
|
5
|
-
import type { CGAPIStrategy } from '../foundation/renderer/CGAPIStrategy';
|
|
6
|
-
import type { RenderPass } from '../foundation/renderer/RenderPass';
|
|
7
|
-
import type { Engine } from '../foundation/system/Engine';
|
|
8
|
-
import type { CGAPIResourceHandle, Count, Index, PrimitiveUID, WebGLResourceHandle } from '../types/CommonTypes';
|
|
9
|
-
import type { WebGLContextWrapper } from './WebGLContextWrapper';
|
|
10
|
-
import type { ShaderSources, WebGLStrategy } from './WebGLStrategy';
|
|
11
|
-
/**
|
|
12
|
-
* WebGL rendering strategy implementation using uniform-based approach.
|
|
13
|
-
* This strategy uses uniforms to pass per-object data to shaders instead of vertex attributes,
|
|
14
|
-
* which is more suitable for rendering multiple objects with different properties.
|
|
15
|
-
*
|
|
16
|
-
* @implements {CGAPIStrategy}
|
|
17
|
-
* @implements {WebGLStrategy}
|
|
18
|
-
*/
|
|
19
|
-
export declare class WebGLStrategyUniform implements CGAPIStrategy, WebGLStrategy {
|
|
20
|
-
private __engine;
|
|
21
|
-
private __dataTextureUid;
|
|
22
|
-
private __morphOffsetsUniformBufferUid;
|
|
23
|
-
private __morphWeightsUniformBufferUid;
|
|
24
|
-
private __uniformMorphOffsetsTypedArray?;
|
|
25
|
-
private __uniformMorphWeightsTypedArray?;
|
|
26
|
-
private __lastShader;
|
|
27
|
-
private __lastMaterial?;
|
|
28
|
-
private __lastRenderPassTickCount;
|
|
29
|
-
private __lastMorphMaxIndex;
|
|
30
|
-
private __lastBlendShapeComponentsUpdateCountForWeights;
|
|
31
|
-
private __lastMorphOffsetsUniformDataSize;
|
|
32
|
-
private __lastMorphWeightsUniformDataSize;
|
|
33
|
-
private __lightComponents?;
|
|
34
|
-
private __countOfBlendShapeComponents;
|
|
35
|
-
/**
|
|
36
|
-
* Shader semantics information for component matrices used in uniform rendering strategy.
|
|
37
|
-
* Defines world matrix, normal matrix, billboard flag, and vertex attributes existence array.
|
|
38
|
-
*/
|
|
39
|
-
private static getComponentMatricesInfoArray;
|
|
40
|
-
/**
|
|
41
|
-
* Private constructor to enforce singleton pattern.
|
|
42
|
-
*/
|
|
43
|
-
private constructor();
|
|
44
|
-
/**
|
|
45
|
-
* method definitions for component data access for uniform-based rendering.
|
|
46
|
-
* Provides GLSL functions for accessing component data through uniforms.
|
|
47
|
-
*/
|
|
48
|
-
private static __getComponentDataAccessMethodDefinitions_uniform;
|
|
49
|
-
private static __getMorphedPositionGetter;
|
|
50
|
-
/**
|
|
51
|
-
* Sets up shader program for the given material and primitive in this WebGL strategy.
|
|
52
|
-
* Creates a new shader program if needed and configures uniform locations for rendering.
|
|
53
|
-
*
|
|
54
|
-
* @param material - The material to setup shader program for
|
|
55
|
-
* @param primitive - The primitive geometry to associate with the shader
|
|
56
|
-
* @returns The CGAPIResourceHandle of the created or existing shader program
|
|
57
|
-
*/
|
|
58
|
-
setupShaderForMaterial(material: Material, primitive: Primitive): CGAPIResourceHandle;
|
|
59
|
-
/**
|
|
60
|
-
* Re-sets up shader program for the material using updated shader sources from Spector.js.
|
|
61
|
-
* This method is specifically designed for shader debugging and live editing scenarios.
|
|
62
|
-
*
|
|
63
|
-
* @param material - The material to re-setup shader program for
|
|
64
|
-
* @param primitive - The primitive geometry associated with the shader
|
|
65
|
-
* @param updatedShaderSources - The updated shader source code
|
|
66
|
-
* @param onError - Callback function to handle compilation errors
|
|
67
|
-
* @returns The CGAPIResourceHandle of the updated shader program, or InvalidCGAPIResourceUid on failure
|
|
68
|
-
*/
|
|
69
|
-
_reSetupShaderForMaterialBySpector(material: Material, primitive: Primitive, updatedShaderSources: ShaderSources, onError: (message: string) => void): CGAPIResourceHandle;
|
|
70
|
-
/**
|
|
71
|
-
* Loads and prepares mesh data for rendering.
|
|
72
|
-
* Sets up VBO (Vertex Buffer Object) and VAO (Vertex Array Object) if not already done.
|
|
73
|
-
*
|
|
74
|
-
* @param meshComponent - The mesh component containing the mesh to load
|
|
75
|
-
* @returns True if the mesh was loaded successfully, false otherwise
|
|
76
|
-
*/
|
|
77
|
-
$load(meshComponent: MeshComponent): boolean;
|
|
78
|
-
private __updateMorphOffsetsUniformBuffersInner;
|
|
79
|
-
private __initMorphUniformBuffers;
|
|
80
|
-
private __bindMorphUniformBuffers;
|
|
81
|
-
/**
|
|
82
|
-
* Updates uniform buffers containing morph target weights for blend shape animation.
|
|
83
|
-
* Copies weight values from blend shape components to GPU-accessible uniform buffers.
|
|
84
|
-
*/
|
|
85
|
-
private __updateMorphWeightsUniformBuffer;
|
|
86
|
-
/**
|
|
87
|
-
* Performs pre-rendering setup operations.
|
|
88
|
-
* Initializes light components, sets up data texture for GPU vertex data,
|
|
89
|
-
* and prepares global rendering state.
|
|
90
|
-
*/
|
|
91
|
-
prerender(): void;
|
|
92
|
-
/**
|
|
93
|
-
* Deletes the current data texture and frees associated GPU resources.
|
|
94
|
-
* This method should be called when the data texture needs to be recreated
|
|
95
|
-
* or when cleaning up resources.
|
|
96
|
-
*
|
|
97
|
-
* @remarks
|
|
98
|
-
* After calling this method, the data texture UID is reset to an invalid state,
|
|
99
|
-
* and a new data texture will be created on the next rendering cycle.
|
|
100
|
-
*/
|
|
101
|
-
deleteDataTexture(engine: Engine): void;
|
|
102
|
-
/**
|
|
103
|
-
* Attaches GPU data for the primitive.
|
|
104
|
-
* This method is part of the CGAPIStrategy interface but is a no-op in uniform strategy
|
|
105
|
-
* as GPU data is handled differently through data textures.
|
|
106
|
-
*
|
|
107
|
-
* @param primitive - The primitive to attach GPU data for
|
|
108
|
-
*/
|
|
109
|
-
attachGPUData(_primitive: Primitive): void;
|
|
110
|
-
/**
|
|
111
|
-
* Attaches vertex data for rendering.
|
|
112
|
-
* This method is part of the CGAPIStrategy interface but is a no-op in uniform strategy
|
|
113
|
-
* as vertex data attachment is handled in attachVertexDataInner.
|
|
114
|
-
*
|
|
115
|
-
* @param i - Index parameter (unused in uniform strategy)
|
|
116
|
-
* @param primitive - The primitive containing vertex data
|
|
117
|
-
* @param glw - WebGL context wrapper
|
|
118
|
-
* @param instanceIDBufferUid - Instance ID buffer handle (unused in uniform strategy)
|
|
119
|
-
*/
|
|
120
|
-
attachVertexData(_i: number, _primitive: Primitive, _glw: WebGLContextWrapper, _instanceIDBufferUid: WebGLResourceHandle): void;
|
|
121
|
-
/**
|
|
122
|
-
* Internal method to attach vertex data for a specific mesh and primitive.
|
|
123
|
-
* Binds the appropriate VAO or sets up vertex data pipeline for rendering.
|
|
124
|
-
*
|
|
125
|
-
* @param mesh - The mesh containing vertex data
|
|
126
|
-
* @param primitive - The primitive geometry to render
|
|
127
|
-
* @param primitiveUid - Unique identifier for the primitive
|
|
128
|
-
* @param glw - WebGL context wrapper
|
|
129
|
-
* @param instanceIDBufferUid - Instance ID buffer handle (unused in uniform strategy)
|
|
130
|
-
*/
|
|
131
|
-
attachVertexDataInner(engine: Engine, mesh: Mesh, primitive: Primitive, primitiveUid: Index, glw: WebGLContextWrapper, instanceIDBufferUid: WebGLResourceHandle): void;
|
|
132
|
-
/**
|
|
133
|
-
* Detaches vertex data and cleans up OpenGL state after rendering.
|
|
134
|
-
* Unbinds VAO, element array buffer, and array buffer to prevent state leakage.
|
|
135
|
-
*
|
|
136
|
-
* @param glw - WebGL context wrapper used for state cleanup
|
|
137
|
-
*/
|
|
138
|
-
dettachVertexData(glw: WebGLContextWrapper): void;
|
|
139
|
-
/**
|
|
140
|
-
* Gets the singleton instance of WebGLStrategyUniform.
|
|
141
|
-
* Initializes the instance and WebXR system if not already created.
|
|
142
|
-
*
|
|
143
|
-
* @returns The singleton instance of WebGLStrategyUniform
|
|
144
|
-
*/
|
|
145
|
-
static init(engine: Engine): WebGLStrategyUniform;
|
|
146
|
-
common_$load(): void;
|
|
147
|
-
private __updateMorphOffsetsUniformBuffers;
|
|
148
|
-
/**
|
|
149
|
-
* Common rendering method that handles the main rendering pipeline.
|
|
150
|
-
* Processes primitives in different rendering phases: opaque, translucent, blend with/without Z-write.
|
|
151
|
-
* Supports buffer-less rendering mode for special cases like post-processing effects.
|
|
152
|
-
*
|
|
153
|
-
* @param primitiveUids - Array of primitive UIDs to render, sorted by rendering order
|
|
154
|
-
* @param renderPass - The render pass configuration containing rendering settings
|
|
155
|
-
* @param renderPassTickCount - Current tick count for the render pass
|
|
156
|
-
* @param displayIdx - The index of the display to render to
|
|
157
|
-
* @returns True if any primitives were rendered, false otherwise
|
|
158
|
-
*/
|
|
159
|
-
common_$render(primitiveUids: PrimitiveUID[], renderPass: RenderPass, renderPassTickCount: Count, _displayIdx: Index): boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Renders primitives without using vertex/index buffers.
|
|
162
|
-
* Used for buffer-less rendering scenarios such as full-screen post-processing effects.
|
|
163
|
-
*
|
|
164
|
-
* @param gl - WebGL2 rendering context
|
|
165
|
-
* @param renderPass - The render pass containing material and rendering configuration
|
|
166
|
-
*/
|
|
167
|
-
private __renderWithoutBuffers;
|
|
168
|
-
/**
|
|
169
|
-
* Internal rendering method for processing individual primitives.
|
|
170
|
-
* Handles shader setup, material parameters, lighting, VR rendering, and draw calls
|
|
171
|
-
* for each mesh entity associated with the primitive.
|
|
172
|
-
*
|
|
173
|
-
* @param primitiveUid - Unique identifier of the primitive to render
|
|
174
|
-
* @param glw - WebGL context wrapper
|
|
175
|
-
* @param renderPass - The render pass configuration
|
|
176
|
-
* @param renderPassTickCount - Current tick count for the render pass
|
|
177
|
-
* @returns True if the primitive was rendered successfully, false otherwise
|
|
178
|
-
*/
|
|
179
|
-
renderInner(primitiveUid: PrimitiveUID, glw: WebGLContextWrapper, renderPass: RenderPass, _renderPassTickCount: Count): boolean;
|
|
180
|
-
/**
|
|
181
|
-
* Binds the data texture containing vertex data to the shader program.
|
|
182
|
-
* The data texture is used to store and access vertex data in uniform rendering strategy.
|
|
183
|
-
*
|
|
184
|
-
* @param gl - WebGL rendering context
|
|
185
|
-
* @param shaderProgram - The shader program to bind the texture to
|
|
186
|
-
*/
|
|
187
|
-
private bindDataTexture;
|
|
188
|
-
/**
|
|
189
|
-
* Destroys all GPU resources held by this strategy.
|
|
190
|
-
* Should be called when the engine is being destroyed.
|
|
191
|
-
*/
|
|
192
|
-
destroy(): void;
|
|
193
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { Config } from '../../core/Config';
|
|
2
|
-
import type { ShapeInstance } from '../../geometry/Shape';
|
|
3
|
-
import type { ISceneGraphEntity } from '../../helpers';
|
|
4
|
-
import { type IVector3 } from '../../math';
|
|
5
|
-
import type { PhysicsBodyProperty, PhysicsColliderProperty, PhysicsMotionProperty, PhysicsPropertyInner } from '../PhysicsProperty';
|
|
6
|
-
import type { PhysicsStrategy } from '../PhysicsStrategy';
|
|
7
|
-
import type { PhysicsWorldProperty } from '../PhysicsWorldProperty';
|
|
8
|
-
/**
|
|
9
|
-
* Physics strategy implementation using the Oimo.js physics engine.
|
|
10
|
-
* This class provides physics simulation capabilities for 3D objects in the scene.
|
|
11
|
-
* It implements the PhysicsStrategy interface to integrate with the Rhodonite framework.
|
|
12
|
-
*/
|
|
13
|
-
export declare class OimoPhysicsStrategy implements PhysicsStrategy {
|
|
14
|
-
/**
|
|
15
|
-
* Global physics world properties shared across all instances.
|
|
16
|
-
* Contains gravity settings and randomization options.
|
|
17
|
-
*/
|
|
18
|
-
static __worldProperty: PhysicsWorldProperty;
|
|
19
|
-
/**
|
|
20
|
-
* The shared Oimo physics world instance.
|
|
21
|
-
* All physics bodies are added to this single world for simulation.
|
|
22
|
-
*/
|
|
23
|
-
static __world: any;
|
|
24
|
-
/**
|
|
25
|
-
* The Oimo physics body associated with this strategy instance.
|
|
26
|
-
*/
|
|
27
|
-
private __body;
|
|
28
|
-
/**
|
|
29
|
-
* The scene graph entity that this physics strategy is attached to.
|
|
30
|
-
*/
|
|
31
|
-
private __entity?;
|
|
32
|
-
/**
|
|
33
|
-
* Cached physics properties used for body recreation when needed.
|
|
34
|
-
*/
|
|
35
|
-
private __property;
|
|
36
|
-
/**
|
|
37
|
-
* The original local scale of the physics shape before any transformations.
|
|
38
|
-
*/
|
|
39
|
-
private __localScale;
|
|
40
|
-
private __shapeLocalPosition;
|
|
41
|
-
private __shapeLocalRotation;
|
|
42
|
-
private __resolvedShapeLocalRotation;
|
|
43
|
-
private __worldScale;
|
|
44
|
-
private __worldSignedScale;
|
|
45
|
-
private __usesShapeInstance;
|
|
46
|
-
private __shapeType?;
|
|
47
|
-
private __warnedScaleApproximation;
|
|
48
|
-
/** Reusable quaternion for world-rotation lookups (avoids per-frame allocations) */
|
|
49
|
-
private __tmpWorldRotation;
|
|
50
|
-
/** Reusable Euler angles for rotation conversions (avoids per-frame allocations) */
|
|
51
|
-
private __tmpEuler;
|
|
52
|
-
/** Reusable temporaries for body pose calculation (avoids per-frame allocations) */
|
|
53
|
-
private __tmpShapeScaledOffset;
|
|
54
|
-
private __tmpBodyWorldOffset;
|
|
55
|
-
private __tmpBodyPose;
|
|
56
|
-
/** Reusable temporaries for the per-frame physics sync */
|
|
57
|
-
private __tmpBodyRotation;
|
|
58
|
-
private __tmpEntityRotation;
|
|
59
|
-
private __tmpInverseLocalRotation;
|
|
60
|
-
private __tmpUpdatePosition;
|
|
61
|
-
/**
|
|
62
|
-
* Creates a new OimoPhysicsStrategy instance.
|
|
63
|
-
* Initializes the shared Oimo physics world if it doesn't exist yet.
|
|
64
|
-
*/
|
|
65
|
-
constructor();
|
|
66
|
-
/**
|
|
67
|
-
* Sets up the physics shape for the given entity with specified properties.
|
|
68
|
-
* Creates a physics body in the Oimo world with the provided configuration.
|
|
69
|
-
*
|
|
70
|
-
* @param prop - The physics properties defining the shape, size, position, and material properties
|
|
71
|
-
* @param entity - The scene graph entity to associate with this physics body
|
|
72
|
-
*/
|
|
73
|
-
setShape(prop: PhysicsPropertyInner, entity: ISceneGraphEntity): void;
|
|
74
|
-
setShapeInstance(shape: ShapeInstance, body: PhysicsBodyProperty, collider: PhysicsColliderProperty, entity: ISceneGraphEntity, worldScale?: IVector3, motion?: PhysicsMotionProperty): void;
|
|
75
|
-
clearShapeInstances(): void;
|
|
76
|
-
/**
|
|
77
|
-
* Updates the associated entity's transform based on the physics body's current state.
|
|
78
|
-
* This method should be called each frame to synchronize the visual representation
|
|
79
|
-
* with the physics simulation results.
|
|
80
|
-
*/
|
|
81
|
-
update(_config: Config): void;
|
|
82
|
-
/**
|
|
83
|
-
* Sets the world position of the physics body.
|
|
84
|
-
* Recreates the physics body with the new position while preserving other properties.
|
|
85
|
-
*
|
|
86
|
-
* @param worldPosition - The new world position to set for the physics body
|
|
87
|
-
*/
|
|
88
|
-
setPosition(worldPosition: IVector3): void;
|
|
89
|
-
/**
|
|
90
|
-
* Sets the rotation of the physics body using Euler angles.
|
|
91
|
-
* Recreates the physics body with the new rotation while preserving other properties.
|
|
92
|
-
*
|
|
93
|
-
* @param eulerAngles - The new Euler angles (in radians) to set for the physics body
|
|
94
|
-
*/
|
|
95
|
-
setEulerAngle(eulerAngles: IVector3): void;
|
|
96
|
-
/**
|
|
97
|
-
* Sets the scale of the physics body.
|
|
98
|
-
* Recreates the physics body with the new scale applied to the original local scale
|
|
99
|
-
* while preserving other properties.
|
|
100
|
-
*
|
|
101
|
-
* @param scale - The scale factors to apply to the physics body's dimensions
|
|
102
|
-
*/
|
|
103
|
-
setScale(scale: IVector3): void;
|
|
104
|
-
private __canCreateBody;
|
|
105
|
-
private __removeBody;
|
|
106
|
-
private __resolveScaledShape;
|
|
107
|
-
private __createLegacyScaledSize;
|
|
108
|
-
private __toBodyPose;
|
|
109
|
-
/**
|
|
110
|
-
* Fills the reusable body pose with the given position and rotation.
|
|
111
|
-
* Accepts plain `{ x, y, z }` objects as well as vector/quaternion instances
|
|
112
|
-
* (Oimo.js returns plain objects from its body getters).
|
|
113
|
-
* @param position - The body position to copy
|
|
114
|
-
* @param rotation - The body rotation to copy
|
|
115
|
-
* @returns The reusable body pose
|
|
116
|
-
*/
|
|
117
|
-
private __reuseBodyPose;
|
|
118
|
-
/**
|
|
119
|
-
* Advances the physics simulation by one time step.
|
|
120
|
-
* This static method should be called once per frame to update all physics bodies
|
|
121
|
-
* in the shared world. It processes collisions, applies forces, and updates positions.
|
|
122
|
-
*/
|
|
123
|
-
static update(): void;
|
|
124
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './OimoPhysicsStrategy';
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import type { MeshComponent } from '../foundation/components/Mesh/MeshComponent';
|
|
2
|
-
import type { Mesh } from '../foundation/geometry/Mesh';
|
|
3
|
-
import { Primitive } from '../foundation/geometry/Primitive';
|
|
4
|
-
import type { Material } from '../foundation/materials/core/Material';
|
|
5
|
-
import type { CGAPIStrategy } from '../foundation/renderer/CGAPIStrategy';
|
|
6
|
-
import type { RenderPass } from '../foundation/renderer/RenderPass';
|
|
7
|
-
import type { Engine } from '../foundation/system/Engine';
|
|
8
|
-
import type { CGAPIResourceHandle, Count, Index, PrimitiveUID, WebGLResourceHandle } from '../types/CommonTypes';
|
|
9
|
-
import type { WebGLContextWrapper } from './WebGLContextWrapper';
|
|
10
|
-
import type { ShaderSources, WebGLStrategy } from './WebGLStrategy';
|
|
11
|
-
/**
|
|
12
|
-
* WebGL rendering strategy implementation using uniform-based approach.
|
|
13
|
-
* This strategy uses uniforms to pass per-object data to shaders instead of vertex attributes,
|
|
14
|
-
* which is more suitable for rendering multiple objects with different properties.
|
|
15
|
-
*
|
|
16
|
-
* @implements {CGAPIStrategy}
|
|
17
|
-
* @implements {WebGLStrategy}
|
|
18
|
-
*/
|
|
19
|
-
export declare class WebGLStrategyUniform implements CGAPIStrategy, WebGLStrategy {
|
|
20
|
-
private __engine;
|
|
21
|
-
private __dataTextureUid;
|
|
22
|
-
private __morphOffsetsUniformBufferUid;
|
|
23
|
-
private __morphWeightsUniformBufferUid;
|
|
24
|
-
private __uniformMorphOffsetsTypedArray?;
|
|
25
|
-
private __uniformMorphWeightsTypedArray?;
|
|
26
|
-
private __lastShader;
|
|
27
|
-
private __lastMaterial?;
|
|
28
|
-
private __lastRenderPassTickCount;
|
|
29
|
-
private __lastMorphMaxIndex;
|
|
30
|
-
private __lastBlendShapeComponentsUpdateCountForWeights;
|
|
31
|
-
private __lastMorphOffsetsUniformDataSize;
|
|
32
|
-
private __lastMorphWeightsUniformDataSize;
|
|
33
|
-
private __lightComponents?;
|
|
34
|
-
private __countOfBlendShapeComponents;
|
|
35
|
-
/**
|
|
36
|
-
* Shader semantics information for component matrices used in uniform rendering strategy.
|
|
37
|
-
* Defines world matrix, normal matrix, billboard flag, and vertex attributes existence array.
|
|
38
|
-
*/
|
|
39
|
-
private static getComponentMatricesInfoArray;
|
|
40
|
-
/**
|
|
41
|
-
* Private constructor to enforce singleton pattern.
|
|
42
|
-
*/
|
|
43
|
-
private constructor();
|
|
44
|
-
/**
|
|
45
|
-
* method definitions for component data access for uniform-based rendering.
|
|
46
|
-
* Provides GLSL functions for accessing component data through uniforms.
|
|
47
|
-
*/
|
|
48
|
-
private static __getComponentDataAccessMethodDefinitions_uniform;
|
|
49
|
-
private static __getMorphedPositionGetter;
|
|
50
|
-
/**
|
|
51
|
-
* Sets up shader program for the given material and primitive in this WebGL strategy.
|
|
52
|
-
* Creates a new shader program if needed and configures uniform locations for rendering.
|
|
53
|
-
*
|
|
54
|
-
* @param material - The material to setup shader program for
|
|
55
|
-
* @param primitive - The primitive geometry to associate with the shader
|
|
56
|
-
* @returns The CGAPIResourceHandle of the created or existing shader program
|
|
57
|
-
*/
|
|
58
|
-
setupShaderForMaterial(material: Material, primitive: Primitive): CGAPIResourceHandle;
|
|
59
|
-
/**
|
|
60
|
-
* Re-sets up shader program for the material using updated shader sources from Spector.js.
|
|
61
|
-
* This method is specifically designed for shader debugging and live editing scenarios.
|
|
62
|
-
*
|
|
63
|
-
* @param material - The material to re-setup shader program for
|
|
64
|
-
* @param primitive - The primitive geometry associated with the shader
|
|
65
|
-
* @param updatedShaderSources - The updated shader source code
|
|
66
|
-
* @param onError - Callback function to handle compilation errors
|
|
67
|
-
* @returns The CGAPIResourceHandle of the updated shader program, or InvalidCGAPIResourceUid on failure
|
|
68
|
-
*/
|
|
69
|
-
_reSetupShaderForMaterialBySpector(material: Material, primitive: Primitive, updatedShaderSources: ShaderSources, onError: (message: string) => void): CGAPIResourceHandle;
|
|
70
|
-
/**
|
|
71
|
-
* Loads and prepares mesh data for rendering.
|
|
72
|
-
* Sets up VBO (Vertex Buffer Object) and VAO (Vertex Array Object) if not already done.
|
|
73
|
-
*
|
|
74
|
-
* @param meshComponent - The mesh component containing the mesh to load
|
|
75
|
-
* @returns True if the mesh was loaded successfully, false otherwise
|
|
76
|
-
*/
|
|
77
|
-
$load(meshComponent: MeshComponent): boolean;
|
|
78
|
-
private __updateMorphOffsetsUniformBuffersInner;
|
|
79
|
-
private __initMorphUniformBuffers;
|
|
80
|
-
private __bindMorphUniformBuffers;
|
|
81
|
-
/**
|
|
82
|
-
* Updates uniform buffers containing morph target weights for blend shape animation.
|
|
83
|
-
* Copies weight values from blend shape components to GPU-accessible uniform buffers.
|
|
84
|
-
*/
|
|
85
|
-
private __updateMorphWeightsUniformBuffer;
|
|
86
|
-
/**
|
|
87
|
-
* Performs pre-rendering setup operations.
|
|
88
|
-
* Initializes light components, sets up data texture for GPU vertex data,
|
|
89
|
-
* and prepares global rendering state.
|
|
90
|
-
*/
|
|
91
|
-
prerender(): void;
|
|
92
|
-
/**
|
|
93
|
-
* Deletes the current data texture and frees associated GPU resources.
|
|
94
|
-
* This method should be called when the data texture needs to be recreated
|
|
95
|
-
* or when cleaning up resources.
|
|
96
|
-
*
|
|
97
|
-
* @remarks
|
|
98
|
-
* After calling this method, the data texture UID is reset to an invalid state,
|
|
99
|
-
* and a new data texture will be created on the next rendering cycle.
|
|
100
|
-
*/
|
|
101
|
-
deleteDataTexture(engine: Engine): void;
|
|
102
|
-
/**
|
|
103
|
-
* Attaches GPU data for the primitive.
|
|
104
|
-
* This method is part of the CGAPIStrategy interface but is a no-op in uniform strategy
|
|
105
|
-
* as GPU data is handled differently through data textures.
|
|
106
|
-
*
|
|
107
|
-
* @param primitive - The primitive to attach GPU data for
|
|
108
|
-
*/
|
|
109
|
-
attachGPUData(_primitive: Primitive): void;
|
|
110
|
-
/**
|
|
111
|
-
* Attaches vertex data for rendering.
|
|
112
|
-
* This method is part of the CGAPIStrategy interface but is a no-op in uniform strategy
|
|
113
|
-
* as vertex data attachment is handled in attachVertexDataInner.
|
|
114
|
-
*
|
|
115
|
-
* @param i - Index parameter (unused in uniform strategy)
|
|
116
|
-
* @param primitive - The primitive containing vertex data
|
|
117
|
-
* @param glw - WebGL context wrapper
|
|
118
|
-
* @param instanceIDBufferUid - Instance ID buffer handle (unused in uniform strategy)
|
|
119
|
-
*/
|
|
120
|
-
attachVertexData(_i: number, _primitive: Primitive, _glw: WebGLContextWrapper, _instanceIDBufferUid: WebGLResourceHandle): void;
|
|
121
|
-
/**
|
|
122
|
-
* Internal method to attach vertex data for a specific mesh and primitive.
|
|
123
|
-
* Binds the appropriate VAO or sets up vertex data pipeline for rendering.
|
|
124
|
-
*
|
|
125
|
-
* @param mesh - The mesh containing vertex data
|
|
126
|
-
* @param primitive - The primitive geometry to render
|
|
127
|
-
* @param primitiveUid - Unique identifier for the primitive
|
|
128
|
-
* @param glw - WebGL context wrapper
|
|
129
|
-
* @param instanceIDBufferUid - Instance ID buffer handle (unused in uniform strategy)
|
|
130
|
-
*/
|
|
131
|
-
attachVertexDataInner(engine: Engine, mesh: Mesh, primitive: Primitive, primitiveUid: Index, glw: WebGLContextWrapper, instanceIDBufferUid: WebGLResourceHandle): void;
|
|
132
|
-
/**
|
|
133
|
-
* Detaches vertex data and cleans up OpenGL state after rendering.
|
|
134
|
-
* Unbinds VAO, element array buffer, and array buffer to prevent state leakage.
|
|
135
|
-
*
|
|
136
|
-
* @param glw - WebGL context wrapper used for state cleanup
|
|
137
|
-
*/
|
|
138
|
-
dettachVertexData(glw: WebGLContextWrapper): void;
|
|
139
|
-
/**
|
|
140
|
-
* Gets the singleton instance of WebGLStrategyUniform.
|
|
141
|
-
* Initializes the instance and WebXR system if not already created.
|
|
142
|
-
*
|
|
143
|
-
* @returns The singleton instance of WebGLStrategyUniform
|
|
144
|
-
*/
|
|
145
|
-
static init(engine: Engine): WebGLStrategyUniform;
|
|
146
|
-
common_$load(): void;
|
|
147
|
-
private __updateMorphOffsetsUniformBuffers;
|
|
148
|
-
/**
|
|
149
|
-
* Common rendering method that handles the main rendering pipeline.
|
|
150
|
-
* Processes primitives in different rendering phases: opaque, translucent, blend with/without Z-write.
|
|
151
|
-
* Supports buffer-less rendering mode for special cases like post-processing effects.
|
|
152
|
-
*
|
|
153
|
-
* @param primitiveUids - Array of primitive UIDs to render, sorted by rendering order
|
|
154
|
-
* @param renderPass - The render pass configuration containing rendering settings
|
|
155
|
-
* @param renderPassTickCount - Current tick count for the render pass
|
|
156
|
-
* @param displayIdx - The index of the display to render to
|
|
157
|
-
* @returns True if any primitives were rendered, false otherwise
|
|
158
|
-
*/
|
|
159
|
-
common_$render(primitiveUids: PrimitiveUID[], renderPass: RenderPass, renderPassTickCount: Count, _displayIdx: Index): boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Renders primitives without using vertex/index buffers.
|
|
162
|
-
* Used for buffer-less rendering scenarios such as full-screen post-processing effects.
|
|
163
|
-
*
|
|
164
|
-
* @param gl - WebGL2 rendering context
|
|
165
|
-
* @param renderPass - The render pass containing material and rendering configuration
|
|
166
|
-
*/
|
|
167
|
-
private __renderWithoutBuffers;
|
|
168
|
-
/**
|
|
169
|
-
* Internal rendering method for processing individual primitives.
|
|
170
|
-
* Handles shader setup, material parameters, lighting, VR rendering, and draw calls
|
|
171
|
-
* for each mesh entity associated with the primitive.
|
|
172
|
-
*
|
|
173
|
-
* @param primitiveUid - Unique identifier of the primitive to render
|
|
174
|
-
* @param glw - WebGL context wrapper
|
|
175
|
-
* @param renderPass - The render pass configuration
|
|
176
|
-
* @param renderPassTickCount - Current tick count for the render pass
|
|
177
|
-
* @returns True if the primitive was rendered successfully, false otherwise
|
|
178
|
-
*/
|
|
179
|
-
renderInner(primitiveUid: PrimitiveUID, glw: WebGLContextWrapper, renderPass: RenderPass, _renderPassTickCount: Count): boolean;
|
|
180
|
-
/**
|
|
181
|
-
* Binds the data texture containing vertex data to the shader program.
|
|
182
|
-
* The data texture is used to store and access vertex data in uniform rendering strategy.
|
|
183
|
-
*
|
|
184
|
-
* @param gl - WebGL rendering context
|
|
185
|
-
* @param shaderProgram - The shader program to bind the texture to
|
|
186
|
-
*/
|
|
187
|
-
private bindDataTexture;
|
|
188
|
-
/**
|
|
189
|
-
* Destroys all GPU resources held by this strategy.
|
|
190
|
-
* Should be called when the engine is being destroyed.
|
|
191
|
-
*/
|
|
192
|
-
destroy(): void;
|
|
193
|
-
}
|