-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
109 lines (98 loc) · 2.9 KB
/
index.js
File metadata and controls
109 lines (98 loc) · 2.9 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Example of using of the dat.gui controllers.CustomController
* https://github.com/anhr/dat.gui
* @author Andrej Hristoliubov https://anhr.github.io/AboutMe/
*
* @copyright 2011 Data Arts Team, Google Creative Lab
*
* @license under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
import { GUI, controllers } from '../../dat.gui/CustomController/build/dat.gui.module.js';
/**
* Example of subtype of CustomController class.
*
* @class KnobController
*
* @extends dat.controllers.CustomController
*
*/
export class KnobController extends controllers.CustomController {
/**
* Create a KnobController.
* @param {Object} object The object to be manipulated
* @param {string} property The name of the property to be manipulated
* @param {number} a first parameter
* @param {number} b second parameter
*/
constructor( object, property, a, b ) {
super( object, property );
// ... set up options if needed
const _this = this;
//input element
this.__input = document.createElement( 'input' );
this.__input.setAttribute( 'type', 'number' );
this.__input.style.width = '40%';
this.updateDisplay();
this.domElement.appendChild( this.__input );
//button element
var button = document.createElement( 'input' );
button.setAttribute( 'type', 'button' );
button.value = 'Set ' + property;
button.style.width = '50%';
button.onclick = function ( e ) {
object[property] = a + b;
_this.updateDisplay();
}
this.domElement.appendChild( button );
}
updateDisplay() {
this.__input.value = this.getValue();
}
}
/**
* Periodically changes the selected 3D object.
* Adds NumberControllerSlider controller into PlayController for changing of the rate of changing of 3D objects per second.
*
* @class Example of subtype of CustomController class.
*
* @extends dat.controllers.CustomController
*
*/
export class PlayController extends controllers.CustomController {
/**
*
* @param {Function} init Returns an object with elements for adding into "property-name" class element.
*/
constructor( init ) {
super( {
playRate: 1,//Default play rate is 1 changes per second
property: init,
}, 'playRate', 1, 25, 1 );
if ( this.property === undefined )
console.error( 'init() returns ' + this.property );
}
}
/**
* Selects previous or next 3D object
* @class Example of subtype of CustomController class.
*
* @extends dat.controllers.CustomController
*
*/
export class PrevAndNextController extends controllers.CustomController {
/**
*
* @param {Function} init Returns an object with elements for adding into "property-name" class element.
*/
constructor( init ) {
super( {
property: init,
} );
if ( this.property === undefined )
console.error( ' init() returns ' + this.property );
}
}