@sapui5/sap.ui.vbm 1.88.0 → 1.90.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/package.json +1 -1
  2. package/src/sap/ui/vbm/.library +1 -1
  3. package/src/sap/ui/vbm/Adapter.js +46 -8
  4. package/src/sap/ui/vbm/Adapter3D.js +2 -2
  5. package/src/sap/ui/vbm/AnalyticMap.js +16 -18
  6. package/src/sap/ui/vbm/AnalyticMapRenderer.js +1 -1
  7. package/src/sap/ui/vbm/Area.js +1 -1
  8. package/src/sap/ui/vbm/Areas.js +1 -1
  9. package/src/sap/ui/vbm/Box.js +1 -1
  10. package/src/sap/ui/vbm/Boxes.js +1 -1
  11. package/src/sap/ui/vbm/Circle.js +1 -1
  12. package/src/sap/ui/vbm/Circles.js +1 -1
  13. package/src/sap/ui/vbm/Cluster.js +1 -1
  14. package/src/sap/ui/vbm/ClusterBase.js +1 -1
  15. package/src/sap/ui/vbm/ClusterContainer.js +1 -1
  16. package/src/sap/ui/vbm/ClusterDistance.js +1 -1
  17. package/src/sap/ui/vbm/ClusterGrid.js +1 -1
  18. package/src/sap/ui/vbm/ClusterRenderer.js +1 -1
  19. package/src/sap/ui/vbm/ClusterTree.js +1 -1
  20. package/src/sap/ui/vbm/Container.js +1 -1
  21. package/src/sap/ui/vbm/Containers.js +1 -1
  22. package/src/sap/ui/vbm/DragSource.js +1 -1
  23. package/src/sap/ui/vbm/DropTarget.js +1 -1
  24. package/src/sap/ui/vbm/Feature.js +1 -1
  25. package/src/sap/ui/vbm/FeatureCollection.js +1 -1
  26. package/src/sap/ui/vbm/GeoCircle.js +1 -1
  27. package/src/sap/ui/vbm/GeoCircles.js +1 -1
  28. package/src/sap/ui/vbm/GeoJsonLayer.js +1 -1
  29. package/src/sap/ui/vbm/GeoMap.js +16 -6
  30. package/src/sap/ui/vbm/GeoMapRenderer.js +1 -1
  31. package/src/sap/ui/vbm/HeatPoint.js +1 -1
  32. package/src/sap/ui/vbm/Heatmap.js +1 -1
  33. package/src/sap/ui/vbm/Legend.js +1 -1
  34. package/src/sap/ui/vbm/LegendItem.js +1 -1
  35. package/src/sap/ui/vbm/Pie.js +1 -1
  36. package/src/sap/ui/vbm/PieItem.js +1 -1
  37. package/src/sap/ui/vbm/Pies.js +1 -1
  38. package/src/sap/ui/vbm/Region.js +1 -1
  39. package/src/sap/ui/vbm/Resource.js +1 -1
  40. package/src/sap/ui/vbm/Route.js +1 -1
  41. package/src/sap/ui/vbm/Routes.js +1 -1
  42. package/src/sap/ui/vbm/Spot.js +1 -1
  43. package/src/sap/ui/vbm/Spots.js +1 -1
  44. package/src/sap/ui/vbm/VBI.js +1 -1
  45. package/src/sap/ui/vbm/VBIRenderer.js +1 -1
  46. package/src/sap/ui/vbm/Viewport.js +4 -4
  47. package/src/sap/ui/vbm/ViewportRenderer.js +1 -1
  48. package/src/sap/ui/vbm/VoAbstract.js +1 -1
  49. package/src/sap/ui/vbm/VoAggregation.js +1 -1
  50. package/src/sap/ui/vbm/VoBase.js +1 -1
  51. package/src/sap/ui/vbm/adapter3d/ModelHandler.js +2 -2
  52. package/src/sap/ui/vbm/adapter3d/ObjectFactory.js +2 -2
  53. package/src/sap/ui/vbm/adapter3d/PolygonHandler.js +2 -2
  54. package/src/sap/ui/vbm/adapter3d/SceneBuilder.js +15 -7
  55. package/src/sap/ui/vbm/adapter3d/Utilities.js +1 -1
  56. package/src/sap/ui/vbm/adapter3d/VBIJSONParser.js +2 -2
  57. package/src/sap/ui/vbm/adapter3d/thirdparty/DecalGeometry.js +217 -225
  58. package/src/sap/ui/vbm/adapter3d/thirdparty/html2canvas.js +1 -1
  59. package/src/sap/ui/vbm/i18n/messagebundle_en_US_saprigi.properties +1 -1
  60. package/src/sap/ui/vbm/lib/sapmapmanager.js +38 -17
  61. package/src/sap/ui/vbm/lib/sapscene.js +1 -1
  62. package/src/sap/ui/vbm/lib/saputilities.js +7 -7
  63. package/src/sap/ui/vbm/lib/sapvbi.js +1 -1
  64. package/src/sap/ui/vbm/library.js +3 -3
  65. package/src/sap/ui/vbm/themes/base/library.source.less +1 -1
  66. package/src/sap/ui/vbm/themes/sap_belize/library.source.less +1 -1
  67. package/src/sap/ui/vbm/themes/sap_belize_hcb/library.source.less +1 -1
  68. package/src/sap/ui/vbm/themes/sap_belize_hcw/library.source.less +1 -1
  69. package/src/sap/ui/vbm/themes/sap_belize_plus/library.source.less +1 -1
  70. package/src/sap/ui/vbm/themes/sap_bluecrystal/library.source.less +1 -1
  71. package/src/sap/ui/vbm/themes/sap_fiori_3/library.source.less +1 -1
  72. package/src/sap/ui/vbm/themes/sap_fiori_3_dark/library.source.less +1 -1
  73. package/src/sap/ui/vbm/themes/sap_fiori_3_hcb/library.source.less +1 -1
  74. package/src/sap/ui/vbm/themes/sap_fiori_3_hcw/library.source.less +1 -1
  75. package/src/sap/ui/vbm/themes/sap_hcb/library.source.less +1 -1
@@ -1,7 +1,5 @@
1
+ // console.warn( "THREE.DecalGeometry: As part of the transition to ES6 Modules, the files in 'examples/js' were deprecated in May 2020 (r117) and will be deleted in December 2020 (r124). You can find more information about developing using ES6 Modules in https://threejs.org/docs/#manual/en/introduction/Installation." );
1
2
  /**
2
- * @author Mugen87 / https://github.com/Mugen87
3
- * @author spite / https://github.com/spite
4
- *
5
3
  * You can use this geometry to create a decal mesh, that serves different kinds of purposes.
6
4
  * e.g. adding unique details to models, performing dynamic visual environmental changes or covering seams.
7
5
  *
@@ -16,356 +14,350 @@
16
14
  *
17
15
  */
18
16
 
19
- ( function () {
20
-
21
- function DecalGeometry( mesh, position, orientation, size ) {
17
+ THREE.DecalGeometry = function ( mesh, position, orientation, size ) {
22
18
 
23
- THREE.BufferGeometry.call( this );
19
+ THREE.BufferGeometry.call( this );
24
20
 
25
- // buffers
21
+ // buffers
26
22
 
27
- var vertices = [];
28
- var normals = [];
29
- var uvs = [];
23
+ var vertices = [];
24
+ var normals = [];
25
+ var uvs = [];
30
26
 
31
- // helpers
27
+ // helpers
32
28
 
33
- var plane = new THREE.Vector3();
29
+ var plane = new THREE.Vector3();
34
30
 
35
- // this matrix represents the transformation of the decal projector
31
+ // this matrix represents the transformation of the decal projector
36
32
 
37
- var projectorMatrix = new THREE.Matrix4();
38
- projectorMatrix.makeRotationFromEuler( orientation );
39
- projectorMatrix.setPosition( position );
33
+ var projectorMatrix = new THREE.Matrix4();
34
+ projectorMatrix.makeRotationFromEuler( orientation );
35
+ projectorMatrix.setPosition( position );
40
36
 
41
- var projectorMatrixInverse = new THREE.Matrix4().getInverse( projectorMatrix );
37
+ var projectorMatrixInverse = new THREE.Matrix4().getInverse( projectorMatrix );
42
38
 
43
- // generate buffers
39
+ // generate buffers
44
40
 
45
- generate();
41
+ generate();
46
42
 
47
- // build geometry
43
+ // build geometry
48
44
 
49
- this.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
50
- this.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
51
- this.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
45
+ this.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
46
+ this.setAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
47
+ this.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
52
48
 
53
- function generate() {
49
+ function generate() {
54
50
 
55
- var i;
56
- var geometry = new THREE.BufferGeometry();
57
- var decalVertices = [];
51
+ var i;
52
+ var geometry = new THREE.BufferGeometry();
53
+ var decalVertices = [];
58
54
 
59
- var vertex = new THREE.Vector3();
60
- var normal = new THREE.Vector3();
55
+ var vertex = new THREE.Vector3();
56
+ var normal = new THREE.Vector3();
61
57
 
62
- // handle different geometry types
58
+ // handle different geometry types
63
59
 
64
- if ( mesh.geometry.isGeometry ) {
60
+ if ( mesh.geometry.isGeometry ) {
65
61
 
66
- geometry.fromGeometry( mesh.geometry );
62
+ geometry.fromGeometry( mesh.geometry );
67
63
 
68
- } else {
64
+ } else {
69
65
 
70
- geometry.copy( mesh.geometry );
71
-
72
- }
66
+ geometry.copy( mesh.geometry );
73
67
 
74
- var positionAttribute = geometry.attributes.position;
75
- var normalAttribute = geometry.attributes.normal;
68
+ }
76
69
 
77
- // first, create an array of 'DecalVertex' objects
78
- // three consecutive 'DecalVertex' objects represent a single face
79
- //
80
- // this data structure will be later used to perform the clipping
70
+ var positionAttribute = geometry.attributes.position;
71
+ var normalAttribute = geometry.attributes.normal;
81
72
 
82
- if ( geometry.index !== null ) {
73
+ // first, create an array of 'DecalVertex' objects
74
+ // three consecutive 'DecalVertex' objects represent a single face
75
+ //
76
+ // this data structure will be later used to perform the clipping
83
77
 
84
- // indexed BufferGeometry
78
+ if ( geometry.index !== null ) {
85
79
 
86
- var index = geometry.index;
80
+ // indexed BufferGeometry
87
81
 
88
- for ( i = 0; i < index.count; i ++ ) {
82
+ var index = geometry.index;
89
83
 
90
- vertex.fromBufferAttribute( positionAttribute, index.getX( i ) );
91
- normal.fromBufferAttribute( normalAttribute, index.getX( i ) );
84
+ for ( i = 0; i < index.count; i ++ ) {
92
85
 
93
- pushDecalVertex( decalVertices, vertex, normal );
86
+ vertex.fromBufferAttribute( positionAttribute, index.getX( i ) );
87
+ normal.fromBufferAttribute( normalAttribute, index.getX( i ) );
94
88
 
95
- }
89
+ pushDecalVertex( decalVertices, vertex, normal );
96
90
 
97
- } else {
91
+ }
98
92
 
99
- // non-indexed BufferGeometry
93
+ } else {
100
94
 
101
- for ( i = 0; i < positionAttribute.count; i ++ ) {
95
+ // non-indexed BufferGeometry
102
96
 
103
- vertex.fromBufferAttribute( positionAttribute, i );
104
- normal.fromBufferAttribute( normalAttribute, i );
97
+ for ( i = 0; i < positionAttribute.count; i ++ ) {
105
98
 
106
- pushDecalVertex( decalVertices, vertex, normal );
99
+ vertex.fromBufferAttribute( positionAttribute, i );
100
+ normal.fromBufferAttribute( normalAttribute, i );
107
101
 
108
- }
102
+ pushDecalVertex( decalVertices, vertex, normal );
109
103
 
110
104
  }
111
105
 
112
- // if object is mirrored, change order or points in decal vertices array and invert normal as well
113
- if (mesh.matrixWorld.determinant() < 0) {
114
- for(i = 0; i < decalVertices.length; i += 3) {
115
- // change order only
116
- var swap = decalVertices[i];
117
- decalVertices[i + 0] = decalVertices[i + 2];
118
- decalVertices[i + 2] = swap;
119
- // debug: invert normals
120
- // decalVertices[i + 0].normal.negate();
121
- // decalVertices[i + 1].normal.negate();
122
- // decalVertices[i + 2].normal.negate();
123
- }
106
+ }
107
+
108
+ // if object is mirrored, change order or points in decal vertices array and invert normal as well
109
+ if (mesh.matrixWorld.determinant() < 0) {
110
+ for(i = 0; i < decalVertices.length; i += 3) {
111
+ // change order only
112
+ var swap = decalVertices[i];
113
+ decalVertices[i + 0] = decalVertices[i + 2];
114
+ decalVertices[i + 2] = swap;
115
+ // debug: invert normals
116
+ // decalVertices[i + 0].normal.negate();
117
+ // decalVertices[i + 1].normal.negate();
118
+ // decalVertices[i + 2].normal.negate();
124
119
  }
120
+ }
125
121
 
126
- // second, clip the geometry so that it doesn't extend out from the projector
122
+ // second, clip the geometry so that it doesn't extend out from the projector
127
123
 
128
- decalVertices = clipGeometry( decalVertices, plane.set( 1, 0, 0 ) );
129
- decalVertices = clipGeometry( decalVertices, plane.set( - 1, 0, 0 ) );
130
- decalVertices = clipGeometry( decalVertices, plane.set( 0, 1, 0 ) );
131
- decalVertices = clipGeometry( decalVertices, plane.set( 0, - 1, 0 ) );
132
- decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, 1 ) );
133
- decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, - 1 ) );
124
+ decalVertices = clipGeometry( decalVertices, plane.set( 1, 0, 0 ) );
125
+ decalVertices = clipGeometry( decalVertices, plane.set( - 1, 0, 0 ) );
126
+ decalVertices = clipGeometry( decalVertices, plane.set( 0, 1, 0 ) );
127
+ decalVertices = clipGeometry( decalVertices, plane.set( 0, - 1, 0 ) );
128
+ decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, 1 ) );
129
+ decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, - 1 ) );
134
130
 
135
- // third, generate final vertices, normals and uvs
131
+ // third, generate final vertices, normals and uvs
136
132
 
137
- for ( i = 0; i < decalVertices.length; i ++ ) {
133
+ for ( i = 0; i < decalVertices.length; i ++ ) {
138
134
 
139
- var decalVertex = decalVertices[ i ];
135
+ var decalVertex = decalVertices[ i ];
140
136
 
141
- // create texture coordinates (we are still in projector space)
137
+ // create texture coordinates (we are still in projector space)
142
138
 
143
- uvs.push(
144
- 0.5 + ( decalVertex.position.x / size.x ),
145
- 0.5 + ( decalVertex.position.y / size.y )
146
- );
139
+ uvs.push(
140
+ 0.5 + ( decalVertex.position.x / size.x ),
141
+ 0.5 + ( decalVertex.position.y / size.y )
142
+ );
147
143
 
148
- // transform the vertex back to world space
144
+ // transform the vertex back to world space
149
145
 
150
- decalVertex.position.applyMatrix4( projectorMatrix );
146
+ decalVertex.position.applyMatrix4( projectorMatrix );
151
147
 
152
- // now create vertex and normal buffer data
148
+ // now create vertex and normal buffer data
153
149
 
154
- vertices.push( decalVertex.position.x, decalVertex.position.y, decalVertex.position.z );
155
- normals.push( decalVertex.normal.x, decalVertex.normal.y, decalVertex.normal.z );
150
+ vertices.push( decalVertex.position.x, decalVertex.position.y, decalVertex.position.z );
151
+ normals.push( decalVertex.normal.x, decalVertex.normal.y, decalVertex.normal.z );
156
152
 
157
- }
158
153
  }
159
154
 
160
- function pushDecalVertex( decalVertices, vertex, normal ) {
161
-
162
- // transform the vertex to world space, then to projector space
163
- vertex.applyMatrix4( mesh.matrixWorld );
164
- vertex.applyMatrix4( projectorMatrixInverse );
165
-
166
- // transform normal to world space
167
- normal.transformDirection(mesh.matrixWorld);
168
-
169
- decalVertices.push( new DecalVertex( vertex.clone(), normal.clone() ) );
170
- }
155
+ }
171
156
 
172
- function clipGeometry( inVertices, plane ) {
157
+ function pushDecalVertex( decalVertices, vertex, normal ) {
173
158
 
174
- var outVertices = [];
159
+ // transform the vertex to world space, then to projector space
175
160
 
176
- var s = 0.5 * Math.abs( size.dot( plane ) );
161
+ vertex.applyMatrix4( mesh.matrixWorld );
162
+ vertex.applyMatrix4( projectorMatrixInverse );
177
163
 
178
- // a single iteration clips one face,
179
- // which consists of three consecutive 'DecalVertex' objects
164
+ normal.transformDirection( mesh.matrixWorld );
180
165
 
181
- for ( var i = 0; i < inVertices.length; i += 3 ) {
166
+ decalVertices.push( new THREE.DecalVertex( vertex.clone(), normal.clone() ) );
182
167
 
183
- var v1Out, v2Out, v3Out, total = 0;
184
- var nV1, nV2, nV3, nV4;
168
+ }
185
169
 
186
- var d1 = inVertices[ i + 0 ].position.dot( plane ) - s;
187
- var d2 = inVertices[ i + 1 ].position.dot( plane ) - s;
188
- var d3 = inVertices[ i + 2 ].position.dot( plane ) - s;
170
+ function clipGeometry( inVertices, plane ) {
189
171
 
190
- v1Out = d1 > 0;
191
- v2Out = d2 > 0;
192
- v3Out = d3 > 0;
172
+ var outVertices = [];
193
173
 
194
- // calculate, how many vertices of the face lie outside of the clipping plane
174
+ var s = 0.5 * Math.abs( size.dot( plane ) );
195
175
 
196
- total = ( v1Out ? 1 : 0 ) + ( v2Out ? 1 : 0 ) + ( v3Out ? 1 : 0 );
176
+ // a single iteration clips one face,
177
+ // which consists of three consecutive 'DecalVertex' objects
197
178
 
198
- switch ( total ) {
179
+ for ( var i = 0; i < inVertices.length; i += 3 ) {
199
180
 
200
- case 0: {
181
+ var v1Out, v2Out, v3Out, total = 0;
182
+ var nV1, nV2, nV3, nV4;
201
183
 
202
- // the entire face lies inside of the plane, no clipping needed
184
+ var d1 = inVertices[ i + 0 ].position.dot( plane ) - s;
185
+ var d2 = inVertices[ i + 1 ].position.dot( plane ) - s;
186
+ var d3 = inVertices[ i + 2 ].position.dot( plane ) - s;
203
187
 
204
- outVertices.push( inVertices[ i ] );
205
- outVertices.push( inVertices[ i + 1 ] );
206
- outVertices.push( inVertices[ i + 2 ] );
207
- break;
188
+ v1Out = d1 > 0;
189
+ v2Out = d2 > 0;
190
+ v3Out = d3 > 0;
208
191
 
209
- }
192
+ // calculate, how many vertices of the face lie outside of the clipping plane
210
193
 
211
- case 1: {
194
+ total = ( v1Out ? 1 : 0 ) + ( v2Out ? 1 : 0 ) + ( v3Out ? 1 : 0 );
212
195
 
213
- // one vertex lies outside of the plane, perform clipping
196
+ switch ( total ) {
214
197
 
215
- if ( v1Out ) {
198
+ case 0: {
216
199
 
217
- nV1 = inVertices[ i + 1 ];
218
- nV2 = inVertices[ i + 2 ];
219
- nV3 = clip( inVertices[ i ], nV1, plane, s );
220
- nV4 = clip( inVertices[ i ], nV2, plane, s );
200
+ // the entire face lies inside of the plane, no clipping needed
221
201
 
222
- }
202
+ outVertices.push( inVertices[ i ] );
203
+ outVertices.push( inVertices[ i + 1 ] );
204
+ outVertices.push( inVertices[ i + 2 ] );
205
+ break;
223
206
 
224
- if ( v2Out ) {
207
+ }
225
208
 
226
- nV1 = inVertices[ i ];
227
- nV2 = inVertices[ i + 2 ];
228
- nV3 = clip( inVertices[ i + 1 ], nV1, plane, s );
229
- nV4 = clip( inVertices[ i + 1 ], nV2, plane, s );
209
+ case 1: {
230
210
 
231
- outVertices.push( nV3 );
232
- outVertices.push( nV2.clone() );
233
- outVertices.push( nV1.clone() );
211
+ // one vertex lies outside of the plane, perform clipping
234
212
 
235
- outVertices.push( nV2.clone() );
236
- outVertices.push( nV3.clone() );
237
- outVertices.push( nV4 );
238
- break;
213
+ if ( v1Out ) {
239
214
 
240
- }
215
+ nV1 = inVertices[ i + 1 ];
216
+ nV2 = inVertices[ i + 2 ];
217
+ nV3 = clip( inVertices[ i ], nV1, plane, s );
218
+ nV4 = clip( inVertices[ i ], nV2, plane, s );
241
219
 
242
- if ( v3Out ) {
220
+ }
243
221
 
244
- nV1 = inVertices[ i ];
245
- nV2 = inVertices[ i + 1 ];
246
- nV3 = clip( inVertices[ i + 2 ], nV1, plane, s );
247
- nV4 = clip( inVertices[ i + 2 ], nV2, plane, s );
222
+ if ( v2Out ) {
248
223
 
249
- }
224
+ nV1 = inVertices[ i ];
225
+ nV2 = inVertices[ i + 2 ];
226
+ nV3 = clip( inVertices[ i + 1 ], nV1, plane, s );
227
+ nV4 = clip( inVertices[ i + 1 ], nV2, plane, s );
250
228
 
251
- outVertices.push( nV1.clone() );
252
- outVertices.push( nV2.clone() );
253
229
  outVertices.push( nV3 );
254
-
255
- outVertices.push( nV4 );
256
- outVertices.push( nV3.clone() );
257
230
  outVertices.push( nV2.clone() );
231
+ outVertices.push( nV1.clone() );
258
232
 
233
+ outVertices.push( nV2.clone() );
234
+ outVertices.push( nV3.clone() );
235
+ outVertices.push( nV4 );
259
236
  break;
260
237
 
261
238
  }
262
239
 
263
- case 2: {
264
-
265
- // two vertices lies outside of the plane, perform clipping
240
+ if ( v3Out ) {
266
241
 
267
- if ( ! v1Out ) {
242
+ nV1 = inVertices[ i ];
243
+ nV2 = inVertices[ i + 1 ];
244
+ nV3 = clip( inVertices[ i + 2 ], nV1, plane, s );
245
+ nV4 = clip( inVertices[ i + 2 ], nV2, plane, s );
268
246
 
269
- nV1 = inVertices[ i ].clone();
270
- nV2 = clip( nV1, inVertices[ i + 1 ], plane, s );
271
- nV3 = clip( nV1, inVertices[ i + 2 ], plane, s );
272
- outVertices.push( nV1 );
273
- outVertices.push( nV2 );
274
- outVertices.push( nV3 );
247
+ }
275
248
 
276
- }
249
+ outVertices.push( nV1.clone() );
250
+ outVertices.push( nV2.clone() );
251
+ outVertices.push( nV3 );
277
252
 
278
- if ( ! v2Out ) {
253
+ outVertices.push( nV4 );
254
+ outVertices.push( nV3.clone() );
255
+ outVertices.push( nV2.clone() );
279
256
 
280
- nV1 = inVertices[ i + 1 ].clone();
281
- nV2 = clip( nV1, inVertices[ i + 2 ], plane, s );
282
- nV3 = clip( nV1, inVertices[ i ], plane, s );
283
- outVertices.push( nV1 );
284
- outVertices.push( nV2 );
285
- outVertices.push( nV3 );
257
+ break;
286
258
 
287
- }
259
+ }
288
260
 
289
- if ( ! v3Out ) {
261
+ case 2: {
290
262
 
291
- nV1 = inVertices[ i + 2 ].clone();
292
- nV2 = clip( nV1, inVertices[ i ], plane, s );
293
- nV3 = clip( nV1, inVertices[ i + 1 ], plane, s );
294
- outVertices.push( nV1 );
295
- outVertices.push( nV2 );
296
- outVertices.push( nV3 );
263
+ // two vertices lies outside of the plane, perform clipping
297
264
 
298
- }
265
+ if ( ! v1Out ) {
299
266
 
300
- break;
267
+ nV1 = inVertices[ i ].clone();
268
+ nV2 = clip( nV1, inVertices[ i + 1 ], plane, s );
269
+ nV3 = clip( nV1, inVertices[ i + 2 ], plane, s );
270
+ outVertices.push( nV1 );
271
+ outVertices.push( nV2 );
272
+ outVertices.push( nV3 );
301
273
 
302
274
  }
303
275
 
304
- case 3: {
305
-
306
- // the entire face lies outside of the plane, so let's discard the corresponding vertices
276
+ if ( ! v2Out ) {
307
277
 
308
- break;
278
+ nV1 = inVertices[ i + 1 ].clone();
279
+ nV2 = clip( nV1, inVertices[ i + 2 ], plane, s );
280
+ nV3 = clip( nV1, inVertices[ i ], plane, s );
281
+ outVertices.push( nV1 );
282
+ outVertices.push( nV2 );
283
+ outVertices.push( nV3 );
309
284
 
310
285
  }
311
286
 
312
- }
287
+ if ( ! v3Out ) {
313
288
 
314
- }
289
+ nV1 = inVertices[ i + 2 ].clone();
290
+ nV2 = clip( nV1, inVertices[ i ], plane, s );
291
+ nV3 = clip( nV1, inVertices[ i + 1 ], plane, s );
292
+ outVertices.push( nV1 );
293
+ outVertices.push( nV2 );
294
+ outVertices.push( nV3 );
315
295
 
316
- return outVertices;
296
+ }
317
297
 
318
- }
298
+ break;
319
299
 
320
- function clip( v0, v1, p, s ) {
300
+ }
321
301
 
322
- var d0 = v0.position.dot( p ) - s;
323
- var d1 = v1.position.dot( p ) - s;
302
+ case 3: {
324
303
 
325
- var s0 = d0 / ( d0 - d1 );
304
+ // the entire face lies outside of the plane, so let's discard the corresponding vertices
326
305
 
327
- var v = new DecalVertex(
328
- new THREE.Vector3(
329
- v0.position.x + s0 * ( v1.position.x - v0.position.x ),
330
- v0.position.y + s0 * ( v1.position.y - v0.position.y ),
331
- v0.position.z + s0 * ( v1.position.z - v0.position.z )
332
- ),
333
- new THREE.Vector3(
334
- v0.normal.x + s0 * ( v1.normal.x - v0.normal.x ),
335
- v0.normal.y + s0 * ( v1.normal.y - v0.normal.y ),
336
- v0.normal.z + s0 * ( v1.normal.z - v0.normal.z )
337
- )
338
- );
306
+ break;
339
307
 
340
- // need to clip more values (texture coordinates)? do it this way:
341
- // intersectpoint.value = a.value + s * ( b.value - a.value );
308
+ }
342
309
 
343
- return v;
310
+ }
344
311
 
345
312
  }
346
313
 
314
+ return outVertices;
315
+
347
316
  }
348
317
 
349
- DecalGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
350
- DecalGeometry.prototype.constructor = DecalGeometry;
318
+ function clip( v0, v1, p, s ) {
319
+
320
+ var d0 = v0.position.dot( p ) - s;
321
+ var d1 = v1.position.dot( p ) - s;
322
+
323
+ var s0 = d0 / ( d0 - d1 );
351
324
 
352
- // helper
325
+ var v = new THREE.DecalVertex(
326
+ new THREE.Vector3(
327
+ v0.position.x + s0 * ( v1.position.x - v0.position.x ),
328
+ v0.position.y + s0 * ( v1.position.y - v0.position.y ),
329
+ v0.position.z + s0 * ( v1.position.z - v0.position.z )
330
+ ),
331
+ new THREE.Vector3(
332
+ v0.normal.x + s0 * ( v1.normal.x - v0.normal.x ),
333
+ v0.normal.y + s0 * ( v1.normal.y - v0.normal.y ),
334
+ v0.normal.z + s0 * ( v1.normal.z - v0.normal.z )
335
+ )
336
+ );
353
337
 
354
- function DecalVertex( position, normal ) {
338
+ // need to clip more values (texture coordinates)? do it this way:
339
+ // intersectpoint.value = a.value + s * ( b.value - a.value );
355
340
 
356
- this.position = position;
357
- this.normal = normal;
341
+ return v;
358
342
 
359
343
  }
360
344
 
361
- DecalVertex.prototype.clone = function () {
345
+ };
346
+
347
+ THREE.DecalGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
348
+ THREE.DecalGeometry.prototype.constructor = THREE.DecalGeometry;
349
+
350
+ // helper
351
+
352
+ THREE.DecalVertex = function ( position, normal ) {
362
353
 
363
- return new DecalVertex( this.position.clone(), this.normal.clone() );
354
+ this.position = position;
355
+ this.normal = normal;
364
356
 
365
- };
357
+ };
366
358
 
367
- // export
359
+ THREE.DecalVertex.prototype.clone = function () {
368
360
 
369
- THREE.DecalGeometry = DecalGeometry;
361
+ return new this.constructor( this.position.clone(), this.normal.clone() );
370
362
 
371
- } )();
363
+ };