threewebcomponents/ThreeSphere.js

19 lines
707 B
JavaScript

import * as THREE from 'https://esm.sh/three';
import { BaseGeometryElement } from './ThreeBaseGeometry.js';
const attrs_position = [ 'x', 'y', 'z' ];
const attrs_dimensions = [ 'height', 'width', 'depth' ];
export class SphereElement extends BaseGeometryElement {
parentO3DCallback(parent) {
this.geometry = new THREE.SphereGeometry(this.getAttribute('radius')); // width, height, depth
this.material = new THREE.MeshLambertMaterial({ color: this.color });
this.mesh = new THREE.Mesh(this.geometry, this.material);
this.mesh.position.set(this.x, this.y, this.z); // Optional, 0,0,0 is the default
parent.add(this.mesh);
}
}
customElements.define('three-sphere', SphereElement);