bezier curves interpolation
by black strings
CSS
body {
background-color: #000;
margin: 0px;
overflow: hidden;
}
JavaScript
// Simple three.js example
import * as THREE from "https://unpkg.com/[email protected]/build/three.module.js";
import { OrbitControls } from "https://unpkg.com/[email protected]/examples/jsm/controls/OrbitControls.js";
var mesh, renderer, scene, camera, controls;
init();
animate();
function init() {
// renderer
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setPixelRatio( window.devicePixelRatio );
document.body.appendChild( renderer.domElement );
// scene
scene = new THREE.Scene();
// camera
camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.set( 20, 20, 20 );
// controls
controls = new OrbitControls( camera, renderer.domElement );
// ambient
scene.add( new THREE.AmbientLight( 0x222222 ) );
// light
var light = new THREE.DirectionalLight( 0xffffff, 1 );
light.position.set( 20,20, 0 );
scene.add( light );
// axes
scene.add( new THREE.AxesHelper( 20 ) );
// geometry
var geometry = new THREE.SphereGeometry( 5, 12, 8 );
// material
var material = new THREE.MeshPhongMaterial( {
color: 0x00ffff,
flatShading: true,
transparent: true,
opacity: 0.7,
} );
// mesh
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
const d = 20;
const point2d = [
new THREE.Vector2(0,0), new THREE.Vector2(0, d), new THREE.Vector2(d, d), new THREE.Vector2(d,0)
];
/* for(const p of point2d) {
p.multiplyScalar(20.0);
} */
const shape = new THREE.Shape(point2d);
/*shape.moveTo( 0, 0 );
shape.lineTo( 0, 10 );
shape.lineTo( 10, 10 );
shape.lineTo( 10, 0 ); */
const g = new THREE.ShapeGeometry( shape );
const m = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
mesh = new THREE.Mesh( g, m );
mesh.add(new THREE.AxesHelper(10));
...