@sapui5/sap.ui.vbm 1.94.0 → 1.96.2

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 (104) 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 +18 -14
  4. package/src/sap/ui/vbm/Adapter3D.js +2 -2
  5. package/src/sap/ui/vbm/AnalyticMap.js +1 -1
  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 +8 -9
  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 +5 -4
  14. package/src/sap/ui/vbm/ClusterBase.js +5 -8
  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 -2
  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 +4 -6
  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 +10 -11
  29. package/src/sap/ui/vbm/GeoMap.js +4 -3
  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 +41 -9
  45. package/src/sap/ui/vbm/VBIRenderer.js +1 -1
  46. package/src/sap/ui/vbm/Viewport.js +7 -6
  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 +4 -6
  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 +271 -183
  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/ColladaLoader.js +2267 -2509
  58. package/src/sap/ui/vbm/adapter3d/thirdparty/DecalGeometry.js +194 -266
  59. package/src/sap/ui/vbm/adapter3d/thirdparty/OrbitControls.js +1004 -700
  60. package/src/sap/ui/vbm/lib/sapactions.js +12 -9
  61. package/src/sap/ui/vbm/lib/sapautomations.js +12 -13
  62. package/src/sap/ui/vbm/lib/sapconfig.js +11 -3
  63. package/src/sap/ui/vbm/lib/sapdataprovider.js +11 -21
  64. package/src/sap/ui/vbm/lib/sapevents.js +11 -11
  65. package/src/sap/ui/vbm/lib/sapgeolocation.js +10 -3
  66. package/src/sap/ui/vbm/lib/sapgeomath.js +11 -4
  67. package/src/sap/ui/vbm/lib/sapgeotool.js +12 -3
  68. package/src/sap/ui/vbm/lib/sapheatmap.js +28 -25
  69. package/src/sap/ui/vbm/lib/saplabels.js +17 -11
  70. package/src/sap/ui/vbm/lib/saplassotrack.js +11 -5
  71. package/src/sap/ui/vbm/lib/sapmaplayer.js +13 -10
  72. package/src/sap/ui/vbm/lib/sapmapmanager.js +14 -4
  73. package/src/sap/ui/vbm/lib/sapmapprovider.js +11 -5
  74. package/src/sap/ui/vbm/lib/sapnavigation.js +11 -3
  75. package/src/sap/ui/vbm/lib/sapparsing.js +11 -1
  76. package/src/sap/ui/vbm/lib/sappositioning.js +12 -5
  77. package/src/sap/ui/vbm/lib/sapprojection.js +12 -5
  78. package/src/sap/ui/vbm/lib/saprecttrack.js +11 -5
  79. package/src/sap/ui/vbm/lib/sapresources.js +12 -6
  80. package/src/sap/ui/vbm/lib/sapscale.js +15 -5
  81. package/src/sap/ui/vbm/lib/sapscene.js +15 -13
  82. package/src/sap/ui/vbm/lib/saputilities.js +19 -91
  83. package/src/sap/ui/vbm/lib/sapvbcluster.js +14 -6
  84. package/src/sap/ui/vbm/lib/sapvbi.js +11 -42
  85. package/src/sap/ui/vbm/lib/sapvbicontext.js +11 -5
  86. package/src/sap/ui/vbm/lib/sapvbmenu.js +19 -13
  87. package/src/sap/ui/vbm/lib/sapvobase.js +17 -16
  88. package/src/sap/ui/vbm/lib/sapvoutils.js +14 -24
  89. package/src/sap/ui/vbm/lib/sapwindow.js +12 -12
  90. package/src/sap/ui/vbm/library.js +29 -32
  91. package/src/sap/ui/vbm/themes/base/library.source.less +1 -1
  92. package/src/sap/ui/vbm/themes/sap_belize/library.source.less +1 -1
  93. package/src/sap/ui/vbm/themes/sap_belize_hcb/library.source.less +1 -1
  94. package/src/sap/ui/vbm/themes/sap_belize_hcw/library.source.less +1 -1
  95. package/src/sap/ui/vbm/themes/sap_belize_plus/library.source.less +1 -1
  96. package/src/sap/ui/vbm/themes/sap_bluecrystal/library.source.less +1 -1
  97. package/src/sap/ui/vbm/themes/sap_fiori_3/library.source.less +1 -1
  98. package/src/sap/ui/vbm/themes/sap_fiori_3_dark/library.source.less +1 -1
  99. package/src/sap/ui/vbm/themes/sap_fiori_3_hcb/library.source.less +1 -1
  100. package/src/sap/ui/vbm/themes/sap_fiori_3_hcw/library.source.less +1 -1
  101. package/src/sap/ui/vbm/themes/sap_hcb/library.source.less +1 -1
  102. package/src/sap/ui/vbm/themes/sap_horizon/library.source.less +8 -0
  103. package/ui5.yaml +3 -1
  104. package/src/sap/ui/vbm/adapter3d/thirdparty/html2canvas.js +0 -6
@@ -1,363 +1,291 @@
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." );
2
- /**
3
- * You can use this geometry to create a decal mesh, that serves different kinds of purposes.
4
- * e.g. adding unique details to models, performing dynamic visual environmental changes or covering seams.
5
- *
6
- * Constructor parameter:
7
- *
8
- * mesh — Any mesh object
9
- * position — Position of the decal projector
10
- * orientation — Orientation of the decal projector
11
- * size — Size of the decal projector
12
- *
13
- * reference: http://blog.wolfire.com/2009/06/how-to-project-decals/
14
- *
15
- */
1
+ ( function () {
2
+ class DecalGeometry extends THREE.BufferGeometry {
16
3
 
17
- THREE.DecalGeometry = function ( mesh, position, orientation, size ) {
4
+ constructor( mesh, position, orientation, size ) {
18
5
 
19
- THREE.BufferGeometry.call( this );
6
+ super(); // buffers
20
7
 
21
- // buffers
8
+ const vertices = [];
9
+ const normals = [];
10
+ const uvs = []; // helpers
22
11
 
23
- var vertices = [];
24
- var normals = [];
25
- var uvs = [];
12
+ const plane = new THREE.Vector3(); // this matrix represents the transformation of the decal projector
26
13
 
27
- // helpers
14
+ const projectorMatrix = new THREE.Matrix4();
15
+ projectorMatrix.makeRotationFromEuler( orientation );
16
+ projectorMatrix.setPosition( position );
17
+ const projectorMatrixInverse = new THREE.Matrix4();
18
+ projectorMatrixInverse.copy( projectorMatrix ).invert(); // generate buffers
28
19
 
29
- var plane = new THREE.Vector3();
20
+ generate(); // build geometry
30
21
 
31
- // this matrix represents the transformation of the decal projector
22
+ this.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
23
+ this.setAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
24
+ this.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
32
25
 
33
- var projectorMatrix = new THREE.Matrix4();
34
- projectorMatrix.makeRotationFromEuler( orientation );
35
- projectorMatrix.setPosition( position );
26
+ function generate() {
36
27
 
37
- var projectorMatrixInverse = new THREE.Matrix4().getInverse( projectorMatrix );
28
+ let decalVertices = [];
29
+ const vertex = new THREE.Vector3();
30
+ const normal = new THREE.Vector3(); // handle different geometry types
38
31
 
39
- // generate buffers
32
+ if ( mesh.geometry.isGeometry === true ) {
40
33
 
41
- generate();
34
+ console.error( 'THREE.DecalGeometry no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );
35
+ return;
42
36
 
43
- // build geometry
44
-
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 ) );
48
-
49
- function generate() {
50
-
51
- var i;
52
- var geometry = new THREE.BufferGeometry();
53
- var decalVertices = [];
54
-
55
- var vertex = new THREE.Vector3();
56
- var normal = new THREE.Vector3();
57
-
58
- // handle different geometry types
59
-
60
- if ( mesh.geometry.isGeometry ) {
61
-
62
- geometry.fromGeometry( mesh.geometry );
37
+ }
63
38
 
64
- } else {
39
+ const geometry = mesh.geometry;
40
+ const positionAttribute = geometry.attributes.position;
41
+ const normalAttribute = geometry.attributes.normal; // first, create an array of 'DecalVertex' objects
42
+ // three consecutive 'DecalVertex' objects represent a single face
43
+ //
44
+ // this data structure will be later used to perform the clipping
65
45
 
66
- geometry.copy( mesh.geometry );
46
+ if ( geometry.index !== null ) {
67
47
 
68
- }
48
+ // indexed THREE.BufferGeometry
49
+ const index = geometry.index;
69
50
 
70
- var positionAttribute = geometry.attributes.position;
71
- var normalAttribute = geometry.attributes.normal;
51
+ for ( let i = 0; i < index.count; i ++ ) {
72
52
 
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
53
+ vertex.fromBufferAttribute( positionAttribute, index.getX( i ) );
54
+ normal.fromBufferAttribute( normalAttribute, index.getX( i ) );
55
+ pushDecalVertex( decalVertices, vertex, normal );
77
56
 
78
- if ( geometry.index !== null ) {
57
+ }
79
58
 
80
- // indexed BufferGeometry
59
+ } else {
81
60
 
82
- var index = geometry.index;
61
+ // non-indexed THREE.BufferGeometry
62
+ for ( let i = 0; i < positionAttribute.count; i ++ ) {
83
63
 
84
- for ( i = 0; i < index.count; i ++ ) {
64
+ vertex.fromBufferAttribute( positionAttribute, i );
65
+ normal.fromBufferAttribute( normalAttribute, i );
66
+ pushDecalVertex( decalVertices, vertex, normal );
85
67
 
86
- vertex.fromBufferAttribute( positionAttribute, index.getX( i ) );
87
- normal.fromBufferAttribute( normalAttribute, index.getX( i ) );
68
+ }
88
69
 
89
- pushDecalVertex( decalVertices, vertex, normal );
70
+ }
90
71
 
91
- }
72
+ // if object is mirrored, change order of points in decal vertices array
73
+ if (mesh.matrixWorld.determinant() < 0) {
74
+ for(let i = 0; i < decalVertices.length; i += 3) {
75
+ const swap = decalVertices[i];
76
+ decalVertices[i + 0] = decalVertices[i + 2];
77
+ decalVertices[i + 2] = swap;
78
+ }
79
+ }
92
80
 
93
- } else {
81
+ // second, clip the geometry so that it doesn't extend out from the projector
82
+ decalVertices = clipGeometry( decalVertices, plane.set( 1, 0, 0 ) );
83
+ decalVertices = clipGeometry( decalVertices, plane.set( - 1, 0, 0 ) );
84
+ decalVertices = clipGeometry( decalVertices, plane.set( 0, 1, 0 ) );
85
+ decalVertices = clipGeometry( decalVertices, plane.set( 0, - 1, 0 ) );
86
+ decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, 1 ) );
87
+ decalVertices = clipGeometry( decalVertices, plane.set( 0, 0, - 1 ) ); // third, generate final vertices, normals and uvs
94
88
 
95
- // non-indexed BufferGeometry
89
+ for ( let i = 0; i < decalVertices.length; i ++ ) {
96
90
 
97
- for ( i = 0; i < positionAttribute.count; i ++ ) {
91
+ const decalVertex = decalVertices[ i ]; // create texture coordinates (we are still in projector space)
98
92
 
99
- vertex.fromBufferAttribute( positionAttribute, i );
100
- normal.fromBufferAttribute( normalAttribute, i );
93
+ uvs.push( 0.5 + decalVertex.position.x / size.x, 0.5 + decalVertex.position.y / size.y ); // transform the vertex back to world space
101
94
 
102
- pushDecalVertex( decalVertices, vertex, normal );
95
+ decalVertex.position.applyMatrix4( projectorMatrix ); // now create vertex and normal buffer data
103
96
 
104
- }
97
+ vertices.push( decalVertex.position.x, decalVertex.position.y, decalVertex.position.z );
98
+ normals.push( decalVertex.normal.x, decalVertex.normal.y, decalVertex.normal.z );
105
99
 
106
- }
100
+ }
107
101
 
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();
119
102
  }
120
- }
121
-
122
- // second, clip the geometry so that it doesn't extend out from the projector
123
-
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 ) );
130
-
131
- // third, generate final vertices, normals and uvs
132
-
133
- for ( i = 0; i < decalVertices.length; i ++ ) {
134
-
135
- var decalVertex = decalVertices[ i ];
136
-
137
- // create texture coordinates (we are still in projector space)
138
103
 
139
- uvs.push(
140
- 0.5 + ( decalVertex.position.x / size.x ),
141
- 0.5 + ( decalVertex.position.y / size.y )
142
- );
104
+ function pushDecalVertex( decalVertices, vertex, normal ) {
143
105
 
144
- // transform the vertex back to world space
106
+ // transform the vertex to world space, then to projector space
107
+ vertex.applyMatrix4( mesh.matrixWorld );
108
+ vertex.applyMatrix4( projectorMatrixInverse );
109
+ normal.transformDirection( mesh.matrixWorld );
110
+ decalVertices.push( new DecalVertex( vertex.clone(), normal.clone() ) );
145
111
 
146
- decalVertex.position.applyMatrix4( projectorMatrix );
147
-
148
- // now create vertex and normal buffer data
112
+ }
149
113
 
150
- vertices.push( decalVertex.position.x, decalVertex.position.y, decalVertex.position.z );
151
- normals.push( decalVertex.normal.x, decalVertex.normal.y, decalVertex.normal.z );
114
+ function clipGeometry( inVertices, plane ) {
152
115
 
153
- }
116
+ const outVertices = [];
117
+ const s = 0.5 * Math.abs( size.dot( plane ) ); // a single iteration clips one face,
118
+ // which consists of three consecutive 'DecalVertex' objects
154
119
 
155
- }
120
+ for ( let i = 0; i < inVertices.length; i += 3 ) {
156
121
 
157
- function pushDecalVertex( decalVertices, vertex, normal ) {
122
+ let total = 0;
123
+ let nV1;
124
+ let nV2;
125
+ let nV3;
126
+ let nV4;
127
+ const d1 = inVertices[ i + 0 ].position.dot( plane ) - s;
128
+ const d2 = inVertices[ i + 1 ].position.dot( plane ) - s;
129
+ const d3 = inVertices[ i + 2 ].position.dot( plane ) - s;
130
+ const v1Out = d1 > 0;
131
+ const v2Out = d2 > 0;
132
+ const v3Out = d3 > 0; // calculate, how many vertices of the face lie outside of the clipping plane
158
133
 
159
- // transform the vertex to world space, then to projector space
134
+ total = ( v1Out ? 1 : 0 ) + ( v2Out ? 1 : 0 ) + ( v3Out ? 1 : 0 );
160
135
 
161
- vertex.applyMatrix4( mesh.matrixWorld );
162
- vertex.applyMatrix4( projectorMatrixInverse );
136
+ switch ( total ) {
163
137
 
164
- normal.transformDirection( mesh.matrixWorld );
138
+ case 0:
139
+ {
165
140
 
166
- decalVertices.push( new THREE.DecalVertex( vertex.clone(), normal.clone() ) );
141
+ // the entire face lies inside of the plane, no clipping needed
142
+ outVertices.push( inVertices[ i ] );
143
+ outVertices.push( inVertices[ i + 1 ] );
144
+ outVertices.push( inVertices[ i + 2 ] );
145
+ break;
167
146
 
168
- }
147
+ }
169
148
 
170
- function clipGeometry( inVertices, plane ) {
149
+ case 1:
150
+ {
171
151
 
172
- var outVertices = [];
152
+ // one vertex lies outside of the plane, perform clipping
153
+ if ( v1Out ) {
173
154
 
174
- var s = 0.5 * Math.abs( size.dot( plane ) );
155
+ nV1 = inVertices[ i + 1 ];
156
+ nV2 = inVertices[ i + 2 ];
157
+ nV3 = clip( inVertices[ i ], nV1, plane, s );
158
+ nV4 = clip( inVertices[ i ], nV2, plane, s );
175
159
 
176
- // a single iteration clips one face,
177
- // which consists of three consecutive 'DecalVertex' objects
160
+ }
178
161
 
179
- for ( var i = 0; i < inVertices.length; i += 3 ) {
162
+ if ( v2Out ) {
180
163
 
181
- var v1Out, v2Out, v3Out, total = 0;
182
- var nV1, nV2, nV3, nV4;
164
+ nV1 = inVertices[ i ];
165
+ nV2 = inVertices[ i + 2 ];
166
+ nV3 = clip( inVertices[ i + 1 ], nV1, plane, s );
167
+ nV4 = clip( inVertices[ i + 1 ], nV2, plane, s );
168
+ outVertices.push( nV3 );
169
+ outVertices.push( nV2.clone() );
170
+ outVertices.push( nV1.clone() );
171
+ outVertices.push( nV2.clone() );
172
+ outVertices.push( nV3.clone() );
173
+ outVertices.push( nV4 );
174
+ break;
183
175
 
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;
176
+ }
187
177
 
188
- v1Out = d1 > 0;
189
- v2Out = d2 > 0;
190
- v3Out = d3 > 0;
178
+ if ( v3Out ) {
191
179
 
192
- // calculate, how many vertices of the face lie outside of the clipping plane
180
+ nV1 = inVertices[ i ];
181
+ nV2 = inVertices[ i + 1 ];
182
+ nV3 = clip( inVertices[ i + 2 ], nV1, plane, s );
183
+ nV4 = clip( inVertices[ i + 2 ], nV2, plane, s );
193
184
 
194
- total = ( v1Out ? 1 : 0 ) + ( v2Out ? 1 : 0 ) + ( v3Out ? 1 : 0 );
185
+ }
195
186
 
196
- switch ( total ) {
187
+ outVertices.push( nV1.clone() );
188
+ outVertices.push( nV2.clone() );
189
+ outVertices.push( nV3 );
190
+ outVertices.push( nV4 );
191
+ outVertices.push( nV3.clone() );
192
+ outVertices.push( nV2.clone() );
193
+ break;
197
194
 
198
- case 0: {
195
+ }
199
196
 
200
- // the entire face lies inside of the plane, no clipping needed
197
+ case 2:
198
+ {
201
199
 
202
- outVertices.push( inVertices[ i ] );
203
- outVertices.push( inVertices[ i + 1 ] );
204
- outVertices.push( inVertices[ i + 2 ] );
205
- break;
200
+ // two vertices lies outside of the plane, perform clipping
201
+ if ( ! v1Out ) {
206
202
 
207
- }
203
+ nV1 = inVertices[ i ].clone();
204
+ nV2 = clip( nV1, inVertices[ i + 1 ], plane, s );
205
+ nV3 = clip( nV1, inVertices[ i + 2 ], plane, s );
206
+ outVertices.push( nV1 );
207
+ outVertices.push( nV2 );
208
+ outVertices.push( nV3 );
208
209
 
209
- case 1: {
210
+ }
210
211
 
211
- // one vertex lies outside of the plane, perform clipping
212
+ if ( ! v2Out ) {
212
213
 
213
- if ( v1Out ) {
214
+ nV1 = inVertices[ i + 1 ].clone();
215
+ nV2 = clip( nV1, inVertices[ i + 2 ], plane, s );
216
+ nV3 = clip( nV1, inVertices[ i ], plane, s );
217
+ outVertices.push( nV1 );
218
+ outVertices.push( nV2 );
219
+ outVertices.push( nV3 );
214
220
 
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 );
221
+ }
219
222
 
220
- }
223
+ if ( ! v3Out ) {
221
224
 
222
- if ( v2Out ) {
225
+ nV1 = inVertices[ i + 2 ].clone();
226
+ nV2 = clip( nV1, inVertices[ i ], plane, s );
227
+ nV3 = clip( nV1, inVertices[ i + 1 ], plane, s );
228
+ outVertices.push( nV1 );
229
+ outVertices.push( nV2 );
230
+ outVertices.push( nV3 );
223
231
 
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 );
232
+ }
228
233
 
229
- outVertices.push( nV3 );
230
- outVertices.push( nV2.clone() );
231
- outVertices.push( nV1.clone() );
234
+ break;
232
235
 
233
- outVertices.push( nV2.clone() );
234
- outVertices.push( nV3.clone() );
235
- outVertices.push( nV4 );
236
- break;
236
+ }
237
237
 
238
- }
238
+ case 3:
239
+ {
239
240
 
240
- if ( v3Out ) {
241
+ // the entire face lies outside of the plane, so let's discard the corresponding vertices
242
+ break;
241
243
 
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 );
244
+ }
246
245
 
247
246
  }
248
247
 
249
- outVertices.push( nV1.clone() );
250
- outVertices.push( nV2.clone() );
251
- outVertices.push( nV3 );
252
-
253
- outVertices.push( nV4 );
254
- outVertices.push( nV3.clone() );
255
- outVertices.push( nV2.clone() );
256
-
257
- break;
258
-
259
248
  }
260
249
 
261
- case 2: {
262
-
263
- // two vertices lies outside of the plane, perform clipping
264
-
265
- if ( ! v1Out ) {
266
-
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 );
273
-
274
- }
275
-
276
- if ( ! v2Out ) {
277
-
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 );
284
-
285
- }
286
-
287
- if ( ! v3Out ) {
288
-
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 );
295
-
296
- }
297
-
298
- break;
299
-
300
- }
250
+ return outVertices;
301
251
 
302
- case 3: {
252
+ }
303
253
 
304
- // the entire face lies outside of the plane, so let's discard the corresponding vertices
254
+ function clip( v0, v1, p, s ) {
305
255
 
306
- break;
256
+ const d0 = v0.position.dot( p ) - s;
257
+ const d1 = v1.position.dot( p ) - s;
258
+ const s0 = d0 / ( d0 - d1 );
259
+ const v = new DecalVertex( new THREE.Vector3( v0.position.x + s0 * ( v1.position.x - v0.position.x ), v0.position.y + s0 * ( v1.position.y - v0.position.y ), v0.position.z + s0 * ( v1.position.z - v0.position.z ) ), new THREE.Vector3( v0.normal.x + s0 * ( v1.normal.x - v0.normal.x ), v0.normal.y + s0 * ( v1.normal.y - v0.normal.y ), v0.normal.z + s0 * ( v1.normal.z - v0.normal.z ) ) ); // need to clip more values (texture coordinates)? do it this way:
260
+ // intersectpoint.value = a.value + s * ( b.value - a.value );
307
261
 
308
- }
262
+ return v;
309
263
 
310
264
  }
311
265
 
312
266
  }
313
267
 
314
- return outVertices;
315
-
316
- }
317
-
318
- function clip( v0, v1, p, s ) {
268
+ } // helper
319
269
 
320
- var d0 = v0.position.dot( p ) - s;
321
- var d1 = v1.position.dot( p ) - s;
322
270
 
323
- var s0 = d0 / ( d0 - d1 );
271
+ class DecalVertex {
324
272
 
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
- );
273
+ constructor( position, normal ) {
337
274
 
338
- // need to clip more values (texture coordinates)? do it this way:
339
- // intersectpoint.value = a.value + s * ( b.value - a.value );
275
+ this.position = position;
276
+ this.normal = normal;
340
277
 
341
- return v;
342
-
343
- }
344
-
345
- };
346
-
347
- THREE.DecalGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
348
- THREE.DecalGeometry.prototype.constructor = THREE.DecalGeometry;
349
-
350
- // helper
278
+ }
351
279
 
352
- THREE.DecalVertex = function ( position, normal ) {
280
+ clone() {
353
281
 
354
- this.position = position;
355
- this.normal = normal;
282
+ return new this.constructor( this.position.clone(), this.normal.clone() );
356
283
 
357
- };
284
+ }
358
285
 
359
- THREE.DecalVertex.prototype.clone = function () {
286
+ }
360
287
 
361
- return new this.constructor( this.position.clone(), this.normal.clone() );
288
+ THREE.DecalGeometry = DecalGeometry;
289
+ THREE.DecalVertex = DecalVertex;
362
290
 
363
- };
291
+ } )();