Mercurial > hg > orthanc-stl
comparison Sources/viewer.js @ 1:0f03a8a0bd6f
encoding of RT-STRUCT as STL
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 17 Jul 2023 18:54:31 +0200 |
parents | 4e889a8e8be2 |
children | 549ba7ada071 |
comparison
equal
deleted
inserted
replaced
0:4e889a8e8be2 | 1:0f03a8a0bd6f |
---|---|
63 light2.position.set(10, 10, 10); | 63 light2.position.set(10, 10, 10); |
64 scene.add(light2); | 64 scene.add(light2); |
65 | 65 |
66 const loader = new STLLoader() | 66 const loader = new STLLoader() |
67 loader.load( | 67 loader.load( |
68 '../instances/' + instanceId + '/content/0042-0011', | 68 '../../instances/' + instanceId + '/content/0042-0011', |
69 function (geometry) { | 69 function (geometry) { |
70 const frustumSize = 200; | 70 const frustumSize = 200; |
71 | 71 |
72 geometry.computeBoundingBox(); | 72 geometry.computeBoundingBox(); |
73 geometry.translate(-(geometry.boundingBox.min.x + geometry.boundingBox.max.x) / 2.0, | 73 geometry.translate(-(geometry.boundingBox.min.x + geometry.boundingBox.max.x) / 2.0, |
74 -(geometry.boundingBox.min.y + geometry.boundingBox.max.y) / 2.0, | 74 -(geometry.boundingBox.min.y + geometry.boundingBox.max.y) / 2.0, |
75 -(geometry.boundingBox.min.z + geometry.boundingBox.max.z) / 2.0); | 75 -(geometry.boundingBox.min.z + geometry.boundingBox.max.z) / 2.0); |
76 geometry.scale((frustumSize / 2.0) / (geometry.boundingBox.max.x - geometry.boundingBox.min.x), | 76 |
77 (frustumSize / 2.0) / (geometry.boundingBox.max.y - geometry.boundingBox.min.y), | 77 var maxSize = Math.max(geometry.boundingBox.max.x - geometry.boundingBox.min.x, |
78 (frustumSize / 2.0) / (geometry.boundingBox.max.z - geometry.boundingBox.min.z)); | 78 geometry.boundingBox.max.y - geometry.boundingBox.min.y, |
79 geometry.boundingBox.max.z - geometry.boundingBox.min.z); | |
80 | |
81 geometry.scale((frustumSize / 2.0) / maxSize, | |
82 (frustumSize / 2.0) / maxSize, | |
83 (frustumSize / 2.0) / maxSize); | |
79 | 84 |
80 const mesh = new THREE.Mesh(geometry, material); | 85 const mesh = new THREE.Mesh(geometry, material); |
81 scene.add(mesh); | 86 scene.add(mesh); |
82 | 87 |
83 const aspect = window.innerWidth / window.innerHeight; | 88 const aspect = window.innerWidth / window.innerHeight; |