@@ -11,6 +11,22 @@ module.exports = function(strings) {
11
11
}
12
12
13
13
} , { } ] , 2 :[ function ( require , module , exports ) {
14
+ 'use strict' ;
15
+
16
+ var _kinectronForThree = require ( './kinectronForThree' ) ;
17
+
18
+ var _kinectronForThree2 = _interopRequireDefault ( _kinectronForThree ) ;
19
+
20
+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
21
+
22
+ //If three.js is in the global scope attach it
23
+ if ( THREE ) {
24
+ THREE . KinectGeometry = _kinectronForThree2 . default ;
25
+ } else {
26
+ console . log ( 'Three.js was not found, perhaps you forgot to include it?' ) ;
27
+ } //Import the class
28
+
29
+ } , { "./kinectronForThree" :4 } ] , 3 :[ function ( require , module , exports ) {
14
30
"use strict" ;
15
31
16
32
Object . defineProperty ( exports , "__esModule" , {
@@ -32,54 +48,37 @@ var KinectParams = {
32
48
33
49
exports . default = KinectParams ;
34
50
35
- } , { } ] , 3 :[ function ( require , module , exports ) {
36
- 'use strict' ;
37
-
38
- var _kinectron_for_three = require ( './kinectron_for_three' ) ;
39
-
40
- var _kinectron_for_three2 = _interopRequireDefault ( _kinectron_for_three ) ;
41
-
42
- function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
43
-
44
- //If three.js is in the global scope attach it
45
- if ( THREE ) {
46
- THREE . KinectGeometry = _kinectron_for_three2 . default ;
47
- } else {
48
- console . log ( 'Three.js was not found, perhaps you forgot to include it?' ) ;
49
- } //Import the class
50
-
51
- } , { "./kinectron_for_three" :4 } ] , 4 :[ function ( require , module , exports ) {
51
+ } , { } ] , 4 :[ function ( require , module , exports ) {
52
52
'use strict' ;
53
53
54
54
//Only for debugging, make sure to comment out for production
55
55
// import * as THREE from 'three'
56
56
57
- // Static camera parameters
58
-
59
57
Object . defineProperty ( exports , "__esModule" , {
60
58
value : true
61
59
} ) ;
62
60
63
61
var _createClass = function ( ) { function defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } } return function ( Constructor , protoProps , staticProps ) { if ( protoProps ) defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) defineProperties ( Constructor , staticProps ) ; return Constructor ; } ; } ( ) ;
64
62
65
- var _KinectParams = require ( './KinectParams ' ) ;
63
+ var _shaderParams = require ( './shaderParams ' ) ;
66
64
67
- var _KinectParams2 = _interopRequireDefault ( _KinectParams ) ;
65
+ var _shaderParams2 = _interopRequireDefault ( _shaderParams ) ;
68
66
69
67
function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
70
68
71
69
function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
72
70
73
71
var glsl = require ( 'glslify' ) ;
74
72
75
- //Precision params for the geometry
76
- var VERTS_WIDE = 512 ;
77
- var VERTS_TALL = 424 ;
78
-
79
73
var KinectGeometry = function ( ) {
80
74
function KinectGeometry ( ) {
81
75
var _type = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : 'mesh' ;
82
76
77
+ var _this = this ;
78
+
79
+ var vertsWide = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 512 ;
80
+ var vertsTall = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : 424 ;
81
+
83
82
_classCallCheck ( this , KinectGeometry ) ;
84
83
85
84
//Load the shaders
@@ -88,41 +87,12 @@ var KinectGeometry = function () {
88
87
89
88
//Build the geometry but only once! even for multipule instances
90
89
if ( ! KinectGeometry . geo ) {
91
- KinectGeometry . buildGeomtery ( ) ;
90
+ KinectGeometry . buildGeomtery ( vertsWide , vertsTall ) ;
92
91
}
93
- console . log ( _KinectParams2 . default . v2 . fx , _KinectParams2 . default . v2 . fy ) ;
92
+
94
93
//Create the material
95
94
this . material = new THREE . ShaderMaterial ( {
96
- uniforms : {
97
- isPoints : {
98
- type : "b" ,
99
- value : false
100
- } ,
101
- depthMap : {
102
- type : "t" ,
103
- value : null
104
- } ,
105
- texSize : {
106
- type : "vec2" ,
107
- value : new THREE . Vector2 ( 0 , 0 )
108
- } ,
109
- fx : {
110
- type : "f" ,
111
- value : _KinectParams2 . default . v2 . fx
112
- } ,
113
- fy : {
114
- type : "f" ,
115
- value : _KinectParams2 . default . v2 . fy
116
- } ,
117
- cx : {
118
- type : "f" ,
119
- value : _KinectParams2 . default . v2 . cx
120
- } ,
121
- cy : {
122
- type : "f" ,
123
- value : _KinectParams2 . default . v2 . cy
124
- }
125
- } ,
95
+ uniforms : _shaderParams2 . default ,
126
96
vertexShader : kinectronVert ,
127
97
fragmentShader : kinectronFrag ,
128
98
transparent : true
@@ -132,43 +102,68 @@ var KinectGeometry = function () {
132
102
this . material . side = THREE . DoubleSide ;
133
103
134
104
//Switch a few things based on selected rendering type and create the mesh
135
- switch ( _type ) {
136
- case 'wire' :
137
- this . material . wireframe = true ;
138
- this . mesh = new THREE . Mesh ( KinectGeometry . geo , this . material ) ;
139
- break ;
140
-
141
- case 'points' :
142
- this . material . uniforms . isPoints . value = true ;
143
- this . mesh = new THREE . Points ( KinectGeometry . geo , this . material ) ;
144
- break ;
145
-
146
- default :
147
- this . mesh = new THREE . Mesh ( KinectGeometry . geo , this . material ) ;
148
- break ;
149
- }
105
+ this . buildMesh ( _type ) ;
150
106
151
107
var loader = new THREE . TextureLoader ( ) ;
152
- //Hack around scope issue
153
- var me = this ;
154
- loader . load ( '../assets/depth.jpg' , function ( texture ) {
155
- me . material . uniforms . depthMap . value = texture ;
156
- me . material . uniforms . texSize . value = new THREE . Vector2 ( texture . width , texture . height ) ;
108
+
109
+ loader . load ( '../assets/test.jpg' , function ( texture ) {
110
+
111
+ //Filter the texture
112
+ texture . minFilter = THREE . LinearFilter ;
113
+ texture . magFilter = THREE . LinearFilter ;
114
+
115
+ _this . material . uniforms . depthMap . value = texture ;
116
+ _this . material . uniforms . texSize . value = new THREE . Vector2 ( texture . width , texture . height ) ;
157
117
} ) ;
158
118
119
+ //Setup a three clock in case we need time in our shaders - get's updated only if update() is called recursively
120
+ this . clock = new THREE . Clock ( ) ;
121
+
159
122
//Expose the class as an object inside the THREE Object3D
160
123
this . mesh . kinectron = this ;
161
124
162
125
//Return the THREE Object3D instance for the mesh so you can just 'scene.add()' it
163
126
return this . mesh ;
164
127
}
165
128
166
- //A utility method to build a fully tesselated plane geometry
129
+ /***************
130
+ * Class methods
131
+ ***************/
132
+
133
+ //Change rendering type
167
134
168
135
169
- _createClass ( KinectGeometry , null , [ {
136
+ _createClass ( KinectGeometry , [ {
137
+ key : 'buildMesh' ,
138
+ value : function buildMesh ( type ) {
139
+ //Switch a few things based on selected rendering type and create the mesh
140
+ switch ( type ) {
141
+ case 'wire' :
142
+ this . material . wireframe = true ;
143
+ this . mesh = new THREE . Mesh ( KinectGeometry . geo , this . material ) ;
144
+ break ;
145
+
146
+ case 'points' :
147
+ this . material . uniforms . isPoints . value = true ;
148
+ this . mesh = new THREE . Points ( KinectGeometry . geo , this . material ) ;
149
+ break ;
150
+
151
+ default :
152
+ this . mesh = new THREE . Mesh ( KinectGeometry . geo , this . material ) ;
153
+ break ;
154
+ }
155
+ }
156
+
157
+ //A utility method to build a fully tesselated plane geometry
158
+
159
+ } , {
160
+ key : 'update' ,
161
+ value : function update ( ) {
162
+ this . mesh . material . uniforms . time . value = this . clock . getElapsedTime ( ) ;
163
+ }
164
+ } ] , [ {
170
165
key : 'buildGeomtery' ,
171
- value : function buildGeomtery ( ) {
166
+ value : function buildGeomtery ( VERTS_WIDE , VERTS_TALL ) {
172
167
KinectGeometry . geo = new THREE . PlaneBufferGeometry ( 5 , 4 , VERTS_WIDE , VERTS_TALL ) ;
173
168
}
174
169
} ] ) ;
@@ -178,4 +173,50 @@ var KinectGeometry = function () {
178
173
179
174
exports . default = KinectGeometry ;
180
175
181
- } , { "./KinectParams" :2 , "glslify" :1 } ] } , { } , [ 3 ] ) ;
176
+ } , { "./shaderParams" :5 , "glslify" :1 } ] , 5 :[ function ( require , module , exports ) {
177
+ "use strict" ;
178
+
179
+ Object . defineProperty ( exports , "__esModule" , {
180
+ value : true
181
+ } ) ;
182
+
183
+ var _kinectParams = require ( "./kinectParams" ) ;
184
+
185
+ var _kinectParams2 = _interopRequireDefault ( _kinectParams ) ;
186
+
187
+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
188
+
189
+ var ShaderParams = {
190
+ isPoints : {
191
+ type : "b" ,
192
+ value : false
193
+ } ,
194
+ depthMap : {
195
+ type : "t" ,
196
+ value : null
197
+ } ,
198
+ texSize : {
199
+ type : "vec2" ,
200
+ value : new THREE . Vector2 ( 0 , 0 )
201
+ } ,
202
+ fx : {
203
+ type : "f" ,
204
+ value : _kinectParams2 . default . v2 . fx
205
+ } ,
206
+ fy : {
207
+ type : "f" ,
208
+ value : _kinectParams2 . default . v2 . fy
209
+ } ,
210
+ cx : {
211
+ type : "f" ,
212
+ value : _kinectParams2 . default . v2 . cx
213
+ } ,
214
+ cy : {
215
+ type : "f" ,
216
+ value : _kinectParams2 . default . v2 . cy
217
+ }
218
+ } ;
219
+
220
+ exports . default = ShaderParams ;
221
+
222
+ } , { "./kinectParams" :3 } ] } , { } , [ 2 ] ) ;
0 commit comments