don't use super-three

faster loading through geometry re-use
This commit is contained in:
Aaron Kimbre 2022-01-26 19:36:41 -06:00
parent 2a5fad3c87
commit 7bb0e46e56

View File

@ -29,8 +29,8 @@
{% endif %}
</div>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/super-three@0.116.0/build/three.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/super-three@0.116.0/examples/js/controls/OrbitControls.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/three@0.116.0/build/three.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/three@0.116.0/examples/js/controls/OrbitControls.js"></script>
<script type="text/javascript" src="{{ url_for('static', filename='lddviewer/base64-binary.js') }}"></script>
@ -59,8 +59,8 @@
{% endif %}
<script type='module'>
import {MTLLoader} from 'https://cdn.jsdelivr.net/npm/super-three@0.116.0/examples/jsm/loaders/MTLLoader.js'
import {OBJLoader} from 'https://cdn.jsdelivr.net/npm/super-three@0.116.0/examples/jsm/loaders/OBJLoader.js'
import {MTLLoader} from 'https://cdn.jsdelivr.net/npm/three@0.116.0/examples/jsm/loaders/MTLLoader.js'
import {OBJLoader} from 'https://cdn.jsdelivr.net/npm/three@0.116.0/examples/jsm/loaders/OBJLoader.js'
//Three.js stuff
const scene = new THREE.Scene();
let cammatr = new THREE.Matrix4();
@ -589,13 +589,15 @@
for (const bri of this.scene.Bricks){
current += 1
for (const pa of bri.Parts){
let geo = new Geometry(pa.designID, this.database)
if (!(pa.designID in geometriecache)) {
let geo = new Geometry(pa.designID, this.database)
geometriecache[pa.designID] = geo
let geo = 0
if (geometriecache.hasOwnProperty(pa.designID)) {
// console.log(`Re-use brick ${pa.designID}`)
geo = geometriecache[pa.designID]
}
else {
geo = geometriecache[pa.designID]
// console.log(`New brick ${pa.designID}`)
geo = new Geometry(pa.designID, this.database)
geometriecache[pa.designID] = geo
}
let ind = 0