I am interested in developing a rotating cube with concealed dashed lines as shown below.
https://i.sstatic.net/0U2im.gif
However, I encountered the following error message in VS Code
(parameter) shader: any Argument of type '{ color: ColorRepresentation; dashSize: number; gapSize: number; onBeforeCompile: (shader: any) => void; }' is not assignable to parameter of type 'LineDashedMaterialParameters'. Object literal may only specify known properties, and 'onBeforeCompile' does not exist in type 'LineDashedMaterialParameters'.
SpinningCube.ts
console.clear();
import * as THREE from 'three';
import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";
let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(45, innerWidth / innerHeight, 1, 100);
camera.position.set(-10, 10, 10);
let renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(innerWidth, innerHeight);
renderer.setClearColor(0x202020);
document.body.appendChild(renderer.domElement);
window.addEventListener('resize', onWindowResize);
let controls = new OrbitControls(camera, renderer.domElement);
let grid = new THREE.GridHelper(10, 10, 0x808080, 0x808080);
grid.position.y = -0.01;
let box = DashedHiddenEdgesBox(10, 6, 3, "yellow");
box.geometry.translate(0, 2.5, 0);
scene.add(box);
renderer.setAnimationLoop((_) => {
box.rotation.x += 0.01;
box.rotation.y += 0.01;
renderer.render(scene, camera);
});
function DashedHiddenEdgesBox(w: number, h: number, d: number, color: THREE.ColorRepresentation) {
//box base points
let basePts = [
[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1],
[0, 1, 0], [1, 1, 0], [1, 1, 1], [0, 1, 1]
].map(p => { return new THREE.Vector3(p[0], p[1], p[2]) });
// more code goes here...
}
function onWindowResize() {
camera.aspect = innerWidth / innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth, innerHeight);
}
https://i.sstatic.net/fCPED.png
Question
Any suggestions on resolving this issue?
Edit
├── @types/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b1c5d9c3d4d4f1819f8082859f81">[email protected]</a>
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e5918d978080a5d5cbd4d6d0cbd5">[email protected]</a>
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7703045a1b1816131205374e59455941">[email protected]</a>
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="403439302533233229303400746e756e72">[email protected]</a>
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="93e4f6f1e3f2f0f8bef0fffad3a7bdaabda2">[email protected]</a>
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7d0a181f0d1c1e165019180b500e180f0b180f3d49534b534d">[email protected]</a>
├── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="413624233120222a6c2c2433262401746f796f71">[email protected]</a>
└── <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1f687a7d6f7e7c745f2a31292a312f">[email protected]</a>
Link to my repository which could be taken down in the future.