3D viewer: theme-aware canvas/material colors and light overlays
This commit is contained in:
@@ -232,7 +232,8 @@
|
||||
var initSize = canvasSize();
|
||||
var renderer = new THREE.WebGLRenderer({ antialias: true });
|
||||
renderer.setSize(initSize.w, initSize.h);
|
||||
renderer.setClearColor(0x1d2021, 1);
|
||||
var isLight = document.documentElement.classList.contains("theme-light");
|
||||
renderer.setClearColor(isLight ? 0xe8ecd0 : 0x1b1b1b, 1);
|
||||
|
||||
var scene = new THREE.Scene();
|
||||
var camera = new THREE.PerspectiveCamera(45, initSize.w / initSize.h, 0.1, 1000000);
|
||||
@@ -308,7 +309,7 @@
|
||||
geo.setAttribute("position", new THREE.Float32BufferAttribute(e.data.positions, 3));
|
||||
if (e.data.indices) geo.setIndex(new THREE.BufferAttribute(e.data.indices, 1));
|
||||
fixWinding(geo);
|
||||
var mat = new THREE.MeshStandardMaterial({ color: 0xb8bb26, metalness: 0.2, roughness: 0.6, side: THREE.DoubleSide, flatShading: false });
|
||||
var mat = new THREE.MeshStandardMaterial({ color: isLight ? 0x5e81ac : 0x77838a, metalness: 0.2, roughness: 0.6, side: THREE.DoubleSide, flatShading: false });
|
||||
chunkGeometry(geo, group, mat);
|
||||
var tris = (e.data.indices && e.data.indices.length) ? e.data.indices.length / 3 : e.data.positions.length / 9;
|
||||
fit();
|
||||
@@ -330,7 +331,7 @@
|
||||
} else {
|
||||
var geo = new THREE.STLLoader().parse(data.buffer);
|
||||
geo.computeVertexNormals();
|
||||
var mat = new THREE.MeshStandardMaterial({ color: 0xb8bb26, metalness: 0.25, roughness: 0.55, flatShading: true });
|
||||
var mat = new THREE.MeshStandardMaterial({ color: isLight ? 0x5e81ac : 0x77838a, metalness: 0.25, roughness: 0.55, flatShading: true });
|
||||
group.add(new THREE.Mesh(geo, mat));
|
||||
fit();
|
||||
showCanvas();
|
||||
|
||||
Reference in New Issue
Block a user