forked from aframevr/a-painter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle-sphere.js
More file actions
34 lines (34 loc) · 1.17 KB
/
single-sphere.js
File metadata and controls
34 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* globals AFRAME THREE */
AFRAME.registerBrush('single-sphere',
{
init: function (color, width) {
this.material = new THREE.MeshStandardMaterial({
color: this.data.color,
roughness: 0.6,
metalness: 0.2,
side: THREE.FrontSide,
flatShading: true
});
this.geometry = new THREE.IcosahedronGeometry(1, 2);
this.mesh = new THREE.Mesh(this.geometry, this.material);
this.object3D.add(this.mesh);
this.mesh.visible = false;
this.drawing = document.querySelector('.a-drawing');
this.drawing.object3D.add(this.object3D);
},
addPoint: function (position, orientation, pointerPosition, pressure, timestamp) {
if (!this.firstPoint) {
this.firstPoint = pointerPosition.clone();
this.mesh.position.set(this.firstPoint.x, this.firstPoint.y, this.firstPoint.z)
}
this.mesh.visible = true
var distance = this.firstPoint.distanceTo(pointerPosition);
this.mesh.scale.set(distance, distance, distance);
return true;
},
undo: function () {
this.drawing.object3D.children.pop();
}
},
{thumbnail: 'brushes/thumb_single_sphere.png', spacing: 0.0}
);