示例#1
0
import { Vector3, Object3D, LineBasicMaterial, Geometry, Line } from 'three';
import { darken, hexToRgb, rgbToHex } from 'utils/ColorUtils';
import { IS_SCREENSHOT, IS_CAPTURE } from 'constants';

//a change of direction of x radians triggers a vertex switch in the path (equivalent to adding a vertex);
const SWITCH_TRESHOLD = 0.005;
const vNorm = new Vector3(1, 0, 0);

export default {
	init(color, nVertices, name) {
		this.name = name;
		this.color = IS_SCREENSHOT || IS_CAPTURE ? color : rgbToHex(darken(hexToRgb(color), 0.7));
		this.points = [];
		this.nVertices = nVertices;
		this.lastVertexIdx = this.nVertices - 1;
		this.lastMod = 0;
		this.root = new Object3D();
		this.tracePosition = new Vector3();
	},

	getDisplayObject() {
		return this.root;
	},

	getNew() {
		
		this.detachTrace();

		const material = new LineBasicMaterial({
			color: this.color,
示例#2
0
import { darken, hexToRgb, rgbToHex } from 'utils/ColorUtils';
import { IS_SCREENSHOT, IS_CAPTURE, QUARTER_CIRCLE } from 'constants';


export default {
	init(name, color, isSolid) {
		this.name = name;
		this.added = false;
		this.isSolid = isSolid;
		this.isGradient = !isSolid;
		this.color = color;
	},

	createSolidLine(orbitVertices) {
		const material = new LineBasicMaterial({
			color: IS_SCREENSHOT || IS_CAPTURE ? this.color : rgbToHex(darken(hexToRgb(this.color), 0.5)),
		});
		this.orbitVertices = orbitVertices.map(val => Dimensions.getScaled(val.clone()));
		const orbitGeom = new Geometry();
		orbitGeom.vertices = this.orbitVertices;

		return new Line(orbitGeom, material);
	},

	createGradientLine(orbitVertices) {
		const l = orbitVertices.length;
		this.orbitVertices = orbitVertices.map((val) => {
			return Dimensions.getScaled(val.clone());
		});

		this.nVertices = this.orbitVertices.length;