Mesh constructor
CameraRenderer object or GPUCurtains class object used to create this Mesh.
parameters use to create this Mesh.
The type of the MeshBaseClass
ReadonlyuuidThe universal unique id of the MeshBaseClass
ReadonlyindexIndex of this MeshBaseClass, i.e. creation order
RenderMaterial used by this MeshBaseClass
Geometry used by this MeshBaseClass
RenderTarget to render this Mesh to instead of the canvas context, if any.
OptionaladditionalAdditional output RenderTarget onto which render this Mesh, besides the main outputTarget or screen. Useful for some effects that might need to render the same Mesh twice or more. Beware tho that the Mesh pipeline has to exactly fit the provided RenderTarget render passes descriptors as no checks will be performed here.
RenderBundle used to render this Mesh, if any.
Controls the order in which this MeshBaseClass should be rendered by our Scene
Whether this MeshBaseClass should be treated as transparent. Impacts the render pipeline blend properties
Flag indicating whether this MeshBaseClass is ready to be drawn
Empty object to store any additional data or custom properties into your Mesh.
function assigned to the onReady callback
function assigned to the onBeforeRender callback
function assigned to the onRender callback
function assigned to the onAfterRender callback
function assigned to the onAfterResize callback
callback to run when MeshBaseClass is ready
Callback to execute before updating the Scene matrix stack. This means it is called early and allows to update transformations values before actually setting the Mesh matrices (if any). This also means it won't be called if the Mesh has not been added to the Scene. The callback won't be called if the Renderer is not ready or the Mesh itself is neither ready nor visible.
callback to run just before updating the Scene matrix stack.
Callback to execute right before actually rendering the Mesh. Useful to update uniforms for example. The callback won't be called if the Renderer is not ready or the Mesh itself is neither ready nor visible.
callback to run just before rendering the MeshBaseClass.
Callback to execute just after a Mesh has been rendered. The callback won't be called if the Renderer is not ready or the Mesh itself is neither ready nor visible.
callback to run just after MeshBaseClass has been rendered
Callback to execute just after a Mesh has been resized.
callback to run just after MeshBaseClass has been resized
The CameraRenderer used
The ProjectedMesh DOMFrustum class object
Frustum culling check to use. Accepts OBB, sphere or a boolean. Default to OBB. When set to true, OBB is used.
Margins (in pixels) to applied to the DOM Frustum to determine if this ProjectedMesh should be frustum culled or not
Options used to create this ProjectedMeshBaseClass
function assigned to the onReEnterView callback
function assigned to the onLeaveView callback
Callback to execute when a Mesh is reentering the view frustum.
callback to run when ProjectedMeshBaseClass is reentering the view frustum
Callback to execute when a Mesh is leaving the view frustum.
callback to run when ProjectedMeshBaseClass is leaving the view frustum
Transformation object of the Object3D
Vec3 holding the actual position of this Object3D from its worldMatrix.
Children Object3D in the scene graph, used to compute their own worldMatrix.
Whether at least one of this Object3D matrix needs an update.
Camera object used to compute model view and model view projection matrices
Matrices object of the ProjectedObject3D
Get private #autoRender value
Get/set whether a Mesh is ready or not
Get the transparent property value
Set the transparent property value. Update the RenderMaterial rendering options and Scene stack if needed.
new transparency value
Get our RenderMaterial textures array
Get the current RenderMaterial uniforms
Get the current RenderMaterial storages
Get whether the Mesh is currently in the camera frustum.
Get the visible property value
Set the visible property value
new visibility value
Get our DOMFrustum projected bounding rectangle
Get whether all this Object3D parents are visible or not. Should not be used directly.
Set to false if at least one of this Object3D parent is not visible, true otherwise. Should not be used directly.
New parent visibility value.
Get our quaternion
Get our model matrix
Get our world matrix
Get our model view matrix
Get our camera view matrix
Get our camera projection matrix
Get our model view projection matrix
Get our normal matrix
Remove a Mesh from the renderer and the Scene
OptionalremoveFromRenderer: booleanCalled when the device has been restored
Compute the Mesh geometry if needed
Set our Mesh geometry: create buffers and add attributes to material
Set or update the RenderMaterial rendering options to match the RenderPass descriptor used to draw this Mesh.
RenderPass used to draw this Mesh, default to the renderer renderPass.
Hook used to clean up parameters before sending them to the material.
parameters to clean before sending them to the RenderMaterial
Set or update the Mesh RenderMaterial
new RenderMaterial to use
Set Mesh material attributes
Create a new MediaTexture.
Assign or remove a RenderTarget to this Mesh Since this manipulates the Scene stacks, it can be used to remove a RenderTarget as well.
the RenderTarget to assign or null if we want to remove the current RenderTarget
Resize the textures.
Execute onBeforeRender callback if needed. Called by the Scene before updating the matrix stack.
Current render pass encoder.
Called after having rendered the Mesh
Render our Mesh
current render pass encoder
Remove the Mesh from the Scene and destroy it
Destroy the Mesh
Set or reset this Mesh renderer.
New CameraRenderer or GPUCurtains instance to use.
Assign or remove a RenderBundle to this Mesh.
OptionalrenderBundle: RenderBundlethe RenderBundle to assign or null if we want to remove the current RenderBundle.
OptionalupdateScene: booleanWhether to remove and then re-add the Mesh from the Scene or not.
Reset the matrices buffer binding parent and offset and tell its bind group to update.
Optionaloffset: numberNew offset to use in the parent RenderBundle binding.
Set default shaders if one or both of them are missing
Set the Mesh frustum culling
Set a Mesh matrices uniforms inputs then call MeshBaseClass super method
Update this Mesh camera BindGroup. Useful if the Mesh needs to be rendered with a different camera than the CameraRenderer one.
New camera BindGroup to use. Should be a clon from the CameraRenderer one.
Resize our Mesh
the new bounding rectangle
Apply scale and resize textures
Check if the Mesh lies inside the camera view frustum or not.
Tell our matrices bindings to update if needed and call Mesh base onBeforeRenderPass super.
Only render the Mesh if it is in view frustum. Since render() is actually called before onRenderPass(), we are sure to have fresh frustum bounding rectangle values here.
current render pass
Set our transforms properties and vectors onChange callbacks
Set our model matrix shouldUpdate flag to true (tell it to update)
Update our model matrix
Update our model matrix.
Whether to update the parent worldMatrix beforehand. Default to false.
Whether to update the children worldMatrix afterward. Default to true.
Check whether at least one of the matrix should be updated
Check at each render whether we should update our matrices, and update them if needed
Tell our projection matrix stack to update
Tell our projection matrix stack to update
Tell our projection matrix stack to update
Set our transform and projection matrices
Set our projection matrices shouldUpdate flags to true (tell them to update)
When the world matrix update, tell our projection matrix to update as well
Tell all our matrices to update
Create a 3D Mesh.
A 3D Mesh is a basically a ProjectedObject3D with a Geometry and a RenderMaterial.
You need to pass at least a valid Geometry as parameter.
If no shaders are provided, it will use the normals colors as default shading.
Shaders bindings and default attributes and uniforms
The shaders are automatically patched with the input bind groups and bindings defined in your parameters object, as well as some default attributes and uniforms (see RenderPipelineEntry).
Default shaders
If one or all shaders are missing, the library will use default ones.
Default vertex shader:
Default fragment shader:
Example