@huukhanhnguyen/model / nodeMethods/block
nodeMethods/block
bakeBlock()
bakeBlock(
data,inherited?,deep?):ObjectData[]
Bake a (possibly nested) document into a flat list of renderable leaf documents by exploding every blockData (children live on the document). A non-block document passes through (wrapped in a one-element array). EVERY baked leaf is a fresh object — children placed in more than one spot (e.g. a node + a clone of it) must not share the same document object.
deep (default true) recurses through every nesting level → flat leaves. deep false dissolves ONLY this block by one level: its children are transformed by the placement but a child that is itself a block STAYS a block (used by blockExplode with nested:false).
Parameters
data
inherited?
Inherited = {}
deep?
boolean = true
Returns
expandAndTessellate()
expandAndTessellate(
dataList,curveTolerance?,patterns?):ObjectData[]
Expand BlockData placements to flat leaf documents (bakeBlock), then tessellate each leaf via render(). ONE shared door for formats without instancing (stl/obj) and for resolveView projection that needs flat meshes. Non-block leaves that are already MeshData/polyline pass through render (idempotent triangulation for stream meshes).
A leaf baked out of a PLACED OBJECT (a placeComponent placement — the document carries sourceComponent) is stamped with attributes.placement = that component key: the drawing resolver's REPRESENT rule reads it (views.ts — a placed object is never sectioned, and one whose content carries the view's family draws that symbol instead of its body). A makeBlock/array/looseToBlock wrapper is NOT a placed object and stamps nothing, so grouping geometry never changes how it cuts.
Parameters
dataList
curveTolerance?
number
patterns?
Pattern[]
Returns
looseToBlocks()
looseToBlocks(
dataList):ObjectData[]
Collect loose curves/faces/mesh-islands into nested blocks by connectivity: each connected component (curves with curves, faces with faces, mesh islands inside one buffer — a singleton is a group of 1) becomes ONE blockData with those children inline. Points and already-nested blocks pass through untouched.
Parameters
dataList
Returns
makeBlock()
makeBlock(
dataList):ObjectData[]
Wrap the ENTIRE data array into ONE blockData, unconditionally — no connectivity clustering, no kind filtering (points / faces / curves / already-nested blocks all go in together; see looseToBlocks for the per-cluster variant). Empty input stays empty; nothing to wrap.
Parameters
dataList
Returns
refreshIds()
refreshIds<
T>(value):T
Shallow-copy a document so a placement is independent of its source. Used by node-referencing generators (clone / mesh / placeComponent). A blockData keeps the same objects array reference (shared children are not copied).
Type Parameters
T
T extends object
Parameters
value
T
Returns
T
wrapAsBlocks()
wrapAsBlocks(
dataList):ObjectData[]
Ensure wrappable documents are blockData placements so array ops can share geometry via one children array + N wrappers (instance path).
- Already a group → pass through (keeps its
objectsarray). - Annotation / section → leave raw (not wrappable).
- Other geometry leaf → ONE new placement holding that single leaf + identity transform. Per-leaf props lift onto the placement so apply* after array stamps instances, not the shared children.
Multi-member array: each source keeps its own children array; step-major copies then produce (copies+1)×members placements with members distinct.