stack3js 0.0.0-stage → 0.6.4
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/COMMAND.md +145 -0
- package/LICENSE +21 -0
- package/README.md +304 -2
- package/THIRD-PARTY-LICENSES.md +100 -0
- package/bin/stack3.mjs +5437 -0
- package/blender/import_stack.py +89 -0
- package/examples/future-tank.stack3.json +1 -0
- package/examples/traffic-cone-4view.png +0 -0
- package/meshing/blocks.py +82 -0
- package/meshing/branches.py +62 -0
- package/meshing/dexel.py +67 -0
- package/meshing/field_data.py +19 -0
- package/meshing/finish_blender.py +203 -0
- package/meshing/finishing.py +155 -0
- package/meshing/geometry.py +71 -0
- package/meshing/guided.py +150 -0
- package/meshing/implicit.py +178 -0
- package/meshing/intersection.py +33 -0
- package/meshing/material.py +115 -0
- package/meshing/mesh.py +103 -0
- package/meshing/network.py +136 -0
- package/meshing/regularization.py +213 -0
- package/meshing/sections.py +165 -0
- package/meshing/signed_distance.py +93 -0
- package/package.json +32 -4
- package/references/hard-surface/README.md +40 -0
- package/references/hard-surface/atlas/concrete-barrier-4view.png +0 -0
- package/references/hard-surface/atlas/preview.pipeline.yaml +14 -0
- package/references/hard-surface/case-studies/benchmark/README.md +22 -0
- package/references/hard-surface/case-studies/benchmark/lod-bevel.pipeline.yaml +258 -0
- package/references/hard-surface/finishing/exports.yaml +10 -0
- package/references/hard-surface/finishing/finish-lod.pipeline.yaml +33 -0
- package/references/hard-surface/finishing/inputs/stack/stack.json +1 -0
- package/references/hard-surface/finishing/inputs/stack/stack.png +0 -0
- package/references/hard-surface/finishing/regularize.pipeline.yaml +46 -0
- package/references/hard-surface/measured-depth/sdf/compare.pipeline.yaml +12 -0
- package/references/hard-surface/measured-depth/sdf/inputs/field.npy +0 -0
- package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.json +1 -0
- package/references/hard-surface/measured-depth/sdf/inputs/stack/stack.png +0 -0
- package/references/hard-surface/measured-depth/sdf/inputs/truth.json +1 -0
- package/references/hard-surface/measured-depth/sdf/sdf.guide.json +3 -0
- package/references/hard-surface/measured-depth/triple-dexel/compare.pipeline.yaml +12 -0
- package/references/hard-surface/measured-depth/triple-dexel/dexel.guide.json +3 -0
- package/references/hard-surface/measured-depth/triple-dexel/inputs/fixture.json +22 -0
- package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.json +22 -0
- package/references/hard-surface/measured-depth/triple-dexel/inputs/stack/stack.png +0 -0
- package/references/hard-surface/measured-depth/triple-dexel/inputs/triple-dexel.npz +0 -0
- package/references/hard-surface/schema/pipeline-fragment.schema.json +5 -0
- package/references/hard-surface/schema/pipeline.schema.json +181 -0
- package/schema/pipeline-fragment.schema.json +5 -0
- package/schema/pipeline.schema.json +181 -0
- package/verification/assembly.py +96 -0
- package/verification/landmarks.py +53 -0
- package/verification/panels.py +137 -0
- package/verification/projections.py +135 -0
- package/verification/verify.py +108 -0
- package/viewer/dist/THIRD-PARTY-LICENSES.md +174 -0
- package/viewer/dist/assets/GLTFExporter-xdVCArY-.js +1 -0
- package/viewer/dist/assets/ant-mech-angled-leg-4view-BO2qt1_k.png +0 -0
- package/viewer/dist/assets/ant-mech-body-4view-D9xVPpbc.png +0 -0
- package/viewer/dist/assets/ant-mech-center-leg-4view-BcphjF_G.png +0 -0
- package/viewer/dist/assets/compare-B6DWTZS9.css +1 -0
- package/viewer/dist/assets/compare-Du4RoRQO.js +6 -0
- package/viewer/dist/assets/compare.worker-CgJq-znx.js +21 -0
- package/viewer/dist/assets/concrete-barrier-4view-7PsO3Ftq.png +0 -0
- package/viewer/dist/assets/emscripten-module-uFzwHH0Y.wasm +0 -0
- package/viewer/dist/assets/emscripten-module.browser-BcR5qphc.js +1 -0
- package/viewer/dist/assets/ffi-Boa1QuFa.js +1 -0
- package/viewer/dist/assets/fillet-rover-body-4-view-Chk8Mx4R.png +0 -0
- package/viewer/dist/assets/fillet-rover-wheel-4-view-B-F8flOC.png +0 -0
- package/viewer/dist/assets/hull-4view-BPPqJYUz.png +0 -0
- package/viewer/dist/assets/hull-base-color-4view-DrQmdT3h.png +0 -0
- package/viewer/dist/assets/hull-clay-4view-3Cu-4Hvr.png +0 -0
- package/viewer/dist/assets/hull-depth-4view-DCOdT5ev.png +0 -0
- package/viewer/dist/assets/hull-normal-4view-CvLaFITy.png +0 -0
- package/viewer/dist/assets/inspection-robot-body-4-view-CLMaHFYm.png +0 -0
- package/viewer/dist/assets/inspection-robot-wheel-4-view-27wRsxcs.png +0 -0
- package/viewer/dist/assets/plastic-barrier-4view-DQkTBW_i.png +0 -0
- package/viewer/dist/assets/presets-jXE0t1fU.js +1 -0
- package/viewer/dist/assets/preview-cache-BKV0EZl9.js +1 -0
- package/viewer/dist/assets/project-BzR9Ensg.css +1 -0
- package/viewer/dist/assets/project-DtHHhfo-.js +17 -0
- package/viewer/dist/assets/reconstruct.worker-ONc9GyFO.js +21 -0
- package/viewer/dist/assets/script-engine-Bs3azDYZ.js +6 -0
- package/viewer/dist/assets/style-CMUT8CmM.css +1 -0
- package/viewer/dist/assets/style-D6eZHs3D.js +4004 -0
- package/viewer/dist/assets/tank-hull-4view-B4sMMkP5.png +0 -0
- package/viewer/dist/assets/tank-track-4view-DAIiMTy3.png +0 -0
- package/viewer/dist/assets/tank-turret-4view-Cx0FuNFu.png +0 -0
- package/viewer/dist/assets/traffic-cone-4view-DG-TkITx.png +0 -0
- package/viewer/dist/assets/viewer-DIjS0No7.js +2 -0
- package/viewer/dist/assets/wet-floor-sign-4view-CWJDyeTX.png +0 -0
- package/viewer/dist/compare.html +47 -0
- package/viewer/dist/examples/traffic-cone-4view.png +0 -0
- package/viewer/dist/index.html +148 -0
- package/viewer/dist/playground/index.html +3342 -0
- package/viewer/dist/project.html +83 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""Build a portable Blender scene from a stack3 bundle validated by the calling CLI."""
|
|
2
|
+
import json
|
|
3
|
+
import math
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
import bpy
|
|
8
|
+
from mathutils import Vector
|
|
9
|
+
|
|
10
|
+
folder, output = map(Path, sys.argv[sys.argv.index('--') + 1:])
|
|
11
|
+
meta = json.loads((folder / 'stack.json').read_text())
|
|
12
|
+
bpy.ops.wm.read_factory_settings(use_empty=True)
|
|
13
|
+
scene = bpy.context.scene
|
|
14
|
+
atlas = bpy.data.images.load(str(folder / 'stack.png'))
|
|
15
|
+
atlas.pack()
|
|
16
|
+
width, depth = meta['width'], meta['depth']
|
|
17
|
+
sx, sy, _ = meta['size']
|
|
18
|
+
px, py, pz = meta['pivot']
|
|
19
|
+
spacing = meta['spacing']
|
|
20
|
+
aw, ah = atlas.size
|
|
21
|
+
verts, faces, uvs = [], [], []
|
|
22
|
+
for layer in range(meta['layers']):
|
|
23
|
+
left = (layer % meta['columns']) * width
|
|
24
|
+
top = (layer // meta['columns']) * depth
|
|
25
|
+
z = (layer + .5) * spacing - pz
|
|
26
|
+
start = len(verts)
|
|
27
|
+
faces.append((start, start + 1, start + 2, start + 3))
|
|
28
|
+
for x, y in ((0, 0), (1, 0), (1, 1), (0, 1)):
|
|
29
|
+
verts.append(((x - .5) * sx - px, (y - .5) * sy - py, z))
|
|
30
|
+
uvs.extend(((left + .5 + x * (width - 1)) / aw,
|
|
31
|
+
1 - (top + .5 + y * (depth - 1)) / ah))
|
|
32
|
+
|
|
33
|
+
mesh = bpy.data.meshes.new('Sprite slices')
|
|
34
|
+
mesh.from_pydata(verts, [], faces)
|
|
35
|
+
mesh.update()
|
|
36
|
+
mesh.uv_layers.new(name='Stack atlas').uv.foreach_set('vector', uvs)
|
|
37
|
+
stack = bpy.data.objects.new(folder.name, mesh)
|
|
38
|
+
scene.collection.objects.link(stack)
|
|
39
|
+
mat = bpy.data.materials.new('Sprite color and coverage')
|
|
40
|
+
mat.use_nodes = True
|
|
41
|
+
nodes, links = mat.node_tree.nodes, mat.node_tree.links
|
|
42
|
+
nodes.clear()
|
|
43
|
+
tex = nodes.new('ShaderNodeTexImage')
|
|
44
|
+
tex.image = atlas
|
|
45
|
+
tex.extension = 'CLIP'
|
|
46
|
+
color = nodes.new('ShaderNodeEmission')
|
|
47
|
+
links.new(tex.outputs['Color'], color.inputs['Color'])
|
|
48
|
+
cutoff = nodes.new('ShaderNodeMath')
|
|
49
|
+
cutoff.operation = 'GREATER_THAN'
|
|
50
|
+
cutoff.inputs[1].default_value = .5
|
|
51
|
+
links.new(tex.outputs['Alpha'], cutoff.inputs[0])
|
|
52
|
+
mix = nodes.new('ShaderNodeMixShader')
|
|
53
|
+
links.new(cutoff.outputs[0], mix.inputs[0])
|
|
54
|
+
links.new(nodes.new('ShaderNodeBsdfTransparent').outputs[0], mix.inputs[1])
|
|
55
|
+
links.new(color.outputs[0], mix.inputs[2])
|
|
56
|
+
links.new(mix.outputs[0], nodes.new('ShaderNodeOutputMaterial').inputs['Surface'])
|
|
57
|
+
mesh.materials.append(mat)
|
|
58
|
+
|
|
59
|
+
scene.render.engine = 'BLENDER_EEVEE'
|
|
60
|
+
scene.render.film_transparent = True
|
|
61
|
+
scene.view_settings.view_transform = 'Standard'
|
|
62
|
+
scene.render.resolution_x = scene.render.resolution_y = 720
|
|
63
|
+
scene.render.resolution_percentage = 100
|
|
64
|
+
extent = meta['layers'] * spacing
|
|
65
|
+
center = Vector((-px, -py, extent / 2 - pz))
|
|
66
|
+
radius = math.hypot(sx, sy, extent) / 2
|
|
67
|
+
cam = bpy.data.objects.new('Preview camera', bpy.data.cameras.new('Orthographic'))
|
|
68
|
+
scene.collection.objects.link(cam)
|
|
69
|
+
scene.camera = cam
|
|
70
|
+
cam.data.type = 'ORTHO'
|
|
71
|
+
cam.data.ortho_scale = 2.15 * radius
|
|
72
|
+
direction = Vector((1, 1.4, .85)).normalized()
|
|
73
|
+
cam.location = center + direction * (3 * radius)
|
|
74
|
+
cam.rotation_euler = (-direction).to_track_quat('-Z', 'Y').to_euler()
|
|
75
|
+
cam.data.clip_start = radius * .01
|
|
76
|
+
cam.data.clip_end = radius * 6
|
|
77
|
+
for screen in bpy.data.screens:
|
|
78
|
+
for area in screen.areas:
|
|
79
|
+
if area.type == 'VIEW_3D':
|
|
80
|
+
view = area.spaces.active
|
|
81
|
+
view.region_3d.view_rotation = cam.rotation_euler.to_quaternion()
|
|
82
|
+
view.region_3d.view_perspective = 'ORTHO'
|
|
83
|
+
view.region_3d.view_distance = 3 * radius
|
|
84
|
+
view.region_3d.view_location = center
|
|
85
|
+
view.shading.type = 'MATERIAL'
|
|
86
|
+
view.overlay.show_overlays = False
|
|
87
|
+
bpy.context.view_layer.objects.active = stack
|
|
88
|
+
stack.select_set(True)
|
|
89
|
+
bpy.ops.wm.save_as_mainfile(filepath=str(output), compress=True)
|