THREE.InstancedMesh for each body, one merged outline for each body, one THREE.InstancedMesh for each plan fill and one merged object for the plan lines. The copies stay real elements: they keep their bodies, their plan symbols, their ids and their edits. Only the drawing changes.
A storey also draws its walls, slabs, roofs, columns, beams, stairs and railings through batches: one THREE.BatchedMesh for each material and one merged outline for each outline material. These elements also stay real elements; only the drawing changes.
Use instancedElementId to find the block or the element under a pointer, and isInstancedDrawable to find the objects that draw them.
Import
Example
Notes
- Each instanced drawable has
userData.floorkitInstanced:kind(surface,symbol-fill,symbol-lines,batched,batched-outline,merged-linesormerged-fill),storeyId,assetRefandelementIds. A surface also hasbodyKeyandshapeId. Instanceidraws the blockelementIds[i]. Thesymbol-linesobject draws the plan lines of all blocks of its storey: itsassetRefis*. - A
batchedobject is aTHREE.BatchedMesh: slotidraws a body of the elementelementIds[i], and a hit on it hasbatchId(the slot), notinstanceId. ItsassetRefis empty. Abatched-outlineobject draws the outlines of the batched bodies and a raycaster does not hit it. - A
merged-linesobject is oneTHREE.LineSegmentsof a storey for each line style: it draws the outlines of the block copies and of the bodies that draw themselves, and the plan lines of stairs, railings and fills, with a colour per vertex. A hit on a plan line hasindex, andinstancedElementId(hit)gives the element of that line; a hit on an outline of a body gives none, because the body’s surface is hit first. Amerged-fillobject is aTHREE.BatchedMeshof a storey that draws its plan fills (rooms, stairs, columns, slabs): slotidraws a fill of the elementelementIds[i], andinstancedElementId(hit)gives that element. A selected or dragged element leaves both and draws its own lines and fills until the selection clears. - The copies and the batched bodies themselves are on the render layer
INSTANCED_SOURCE_LAYER(30). A camera and a raycaster on layer 0 do not see them.Box3.expandByObjectstill counts them. The kernel body of each copy and each batched body is host-drawn (OpenGeometry.setHostDrawn): itsvisibleisfalse, so the three.js scene walk skips it, and the kernel still keeps its mesh current. Do not writevisibleon such a body. A part of an element whose whole content its storey draws this way (a body mount, an opening’s group, a plan line or fill) hasvisiblefalsetoo, so the walk skips it; the element’s ownvisible,modelViewandprofileViewkeep their values. While any instanced drawable is hidden, as in the GLB export, these parts are shown again. OpenGeometry.resolveHitgives no body for a hit on an instanced drawable. UseinstancedElementId, not the parents of the hit object.- A change made in place to the material of a batched body does not show. Set the element’s appearance instead: that takes the body out of the batch.
- A copy with its own shape (a mirrored or unevenly scaled copy) and a block with no other copy on its storey draw as before.
isInstancedDrawable
Whetherobject is a storey’s instanced drawable of repeated blocks or of batched elements.
instancedElementId
The live id of the block that a raycaster hit on an instanced drawable shows, or undefined for a hit on anything else.INSTANCED_SOURCE_LAYER
The render layer of a placed block’s own surfaces, outlines and plan symbols while one instanced drawable of its storey draws them: a camera on layer 0 does not draw them, a raycaster on layer 0 does not hit them, and their bounds still count.Types
InstancedDrawableData
What an instanced drawable of a storey draws, on itsuserData.floorkitInstanced.
The storey of the first copy; a surface or symbol fill draws the copies of every storey.