@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.
- package/package.json +1 -1
- package/src/sap/ui/vbm/.library +1 -1
- package/src/sap/ui/vbm/Adapter.js +46 -8
- package/src/sap/ui/vbm/Adapter3D.js +2 -2
- package/src/sap/ui/vbm/AnalyticMap.js +16 -18
- package/src/sap/ui/vbm/AnalyticMapRenderer.js +1 -1
- package/src/sap/ui/vbm/Area.js +1 -1
- package/src/sap/ui/vbm/Areas.js +1 -1
- package/src/sap/ui/vbm/Box.js +1 -1
- package/src/sap/ui/vbm/Boxes.js +1 -1
- package/src/sap/ui/vbm/Circle.js +1 -1
- package/src/sap/ui/vbm/Circles.js +1 -1
- package/src/sap/ui/vbm/Cluster.js +1 -1
- package/src/sap/ui/vbm/ClusterBase.js +1 -1
- package/src/sap/ui/vbm/ClusterContainer.js +1 -1
- package/src/sap/ui/vbm/ClusterDistance.js +1 -1
- package/src/sap/ui/vbm/ClusterGrid.js +1 -1
- package/src/sap/ui/vbm/ClusterRenderer.js +1 -1
- package/src/sap/ui/vbm/ClusterTree.js +1 -1
- package/src/sap/ui/vbm/Container.js +1 -1
- package/src/sap/ui/vbm/Containers.js +1 -1
- package/src/sap/ui/vbm/DragSource.js +1 -1
- package/src/sap/ui/vbm/DropTarget.js +1 -1
- package/src/sap/ui/vbm/Feature.js +1 -1
- package/src/sap/ui/vbm/FeatureCollection.js +1 -1
- package/src/sap/ui/vbm/GeoCircle.js +1 -1
- package/src/sap/ui/vbm/GeoCircles.js +1 -1
- package/src/sap/ui/vbm/GeoJsonLayer.js +1 -1
- package/src/sap/ui/vbm/GeoMap.js +16 -6
- package/src/sap/ui/vbm/GeoMapRenderer.js +1 -1
- package/src/sap/ui/vbm/HeatPoint.js +1 -1
- package/src/sap/ui/vbm/Heatmap.js +1 -1
- package/src/sap/ui/vbm/Legend.js +1 -1
- package/src/sap/ui/vbm/LegendItem.js +1 -1
- package/src/sap/ui/vbm/Pie.js +1 -1
- package/src/sap/ui/vbm/PieItem.js +1 -1
- package/src/sap/ui/vbm/Pies.js +1 -1
- package/src/sap/ui/vbm/Region.js +1 -1
- package/src/sap/ui/vbm/Resource.js +1 -1
- package/src/sap/ui/vbm/Route.js +1 -1
- package/src/sap/ui/vbm/Routes.js +1 -1
- package/src/sap/ui/vbm/Spot.js +1 -1
- package/src/sap/ui/vbm/Spots.js +1 -1
- package/src/sap/ui/vbm/VBI.js +1 -1
- package/src/sap/ui/vbm/VBIRenderer.js +1 -1
- package/src/sap/ui/vbm/Viewport.js +4 -4
- package/src/sap/ui/vbm/ViewportRenderer.js +1 -1
- package/src/sap/ui/vbm/VoAbstract.js +1 -1
- package/src/sap/ui/vbm/VoAggregation.js +1 -1
- package/src/sap/ui/vbm/VoBase.js +1 -1
- package/src/sap/ui/vbm/adapter3d/ModelHandler.js +2 -2
- package/src/sap/ui/vbm/adapter3d/ObjectFactory.js +2 -2
- package/src/sap/ui/vbm/adapter3d/PolygonHandler.js +2 -2
- package/src/sap/ui/vbm/adapter3d/SceneBuilder.js +15 -7
- package/src/sap/ui/vbm/adapter3d/Utilities.js +1 -1
- package/src/sap/ui/vbm/adapter3d/VBIJSONParser.js +2 -2
- package/src/sap/ui/vbm/adapter3d/thirdparty/DecalGeometry.js +217 -225
- package/src/sap/ui/vbm/adapter3d/thirdparty/html2canvas.js +1 -1
- package/src/sap/ui/vbm/i18n/messagebundle_en_US_saprigi.properties +1 -1
- package/src/sap/ui/vbm/lib/sapmapmanager.js +38 -17
- package/src/sap/ui/vbm/lib/sapscene.js +1 -1
- package/src/sap/ui/vbm/lib/saputilities.js +7 -7
- package/src/sap/ui/vbm/lib/sapvbi.js +1 -1
- package/src/sap/ui/vbm/library.js +3 -3
- package/src/sap/ui/vbm/themes/base/library.source.less +1 -1
- package/src/sap/ui/vbm/themes/sap_belize/library.source.less +1 -1
- package/src/sap/ui/vbm/themes/sap_belize_hcb/library.source.less +1 -1
- package/src/sap/ui/vbm/themes/sap_belize_hcw/library.source.less +1 -1
- package/src/sap/ui/vbm/themes/sap_belize_plus/library.source.less +1 -1
- package/src/sap/ui/vbm/themes/sap_bluecrystal/library.source.less +1 -1
- package/src/sap/ui/vbm/themes/sap_fiori_3/library.source.less +1 -1
- package/src/sap/ui/vbm/themes/sap_fiori_3_dark/library.source.less +1 -1
- package/src/sap/ui/vbm/themes/sap_fiori_3_hcb/library.source.less +1 -1
- package/src/sap/ui/vbm/themes/sap_fiori_3_hcw/library.source.less +1 -1
- 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
|
-
|
|
20
|
-
|
|
21
|
-
function DecalGeometry( mesh, position, orientation, size ) {
|
|
17
|
+
THREE.DecalGeometry = function ( mesh, position, orientation, size ) {
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
THREE.BufferGeometry.call( this );
|
|
24
20
|
|
|
25
|
-
|
|
21
|
+
// buffers
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
var vertices = [];
|
|
24
|
+
var normals = [];
|
|
25
|
+
var uvs = [];
|
|
30
26
|
|
|
31
|
-
|
|
27
|
+
// helpers
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
var plane = new THREE.Vector3();
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
// this matrix represents the transformation of the decal projector
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
var projectorMatrix = new THREE.Matrix4();
|
|
34
|
+
projectorMatrix.makeRotationFromEuler( orientation );
|
|
35
|
+
projectorMatrix.setPosition( position );
|
|
40
36
|
|
|
41
|
-
|
|
37
|
+
var projectorMatrixInverse = new THREE.Matrix4().getInverse( projectorMatrix );
|
|
42
38
|
|
|
43
|
-
|
|
39
|
+
// generate buffers
|
|
44
40
|
|
|
45
|
-
|
|
41
|
+
generate();
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
// build geometry
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
49
|
+
function generate() {
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
var i;
|
|
52
|
+
var geometry = new THREE.BufferGeometry();
|
|
53
|
+
var decalVertices = [];
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
var vertex = new THREE.Vector3();
|
|
56
|
+
var normal = new THREE.Vector3();
|
|
61
57
|
|
|
62
|
-
|
|
58
|
+
// handle different geometry types
|
|
63
59
|
|
|
64
|
-
|
|
60
|
+
if ( mesh.geometry.isGeometry ) {
|
|
65
61
|
|
|
66
|
-
|
|
62
|
+
geometry.fromGeometry( mesh.geometry );
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
} else {
|
|
69
65
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
66
|
+
geometry.copy( mesh.geometry );
|
|
73
67
|
|
|
74
|
-
|
|
75
|
-
var normalAttribute = geometry.attributes.normal;
|
|
68
|
+
}
|
|
76
69
|
|
|
77
|
-
|
|
78
|
-
|
|
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
|
-
|
|
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
|
-
|
|
78
|
+
if ( geometry.index !== null ) {
|
|
85
79
|
|
|
86
|
-
|
|
80
|
+
// indexed BufferGeometry
|
|
87
81
|
|
|
88
|
-
|
|
82
|
+
var index = geometry.index;
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
normal.fromBufferAttribute( normalAttribute, index.getX( i ) );
|
|
84
|
+
for ( i = 0; i < index.count; i ++ ) {
|
|
92
85
|
|
|
93
|
-
|
|
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
|
-
}
|
|
91
|
+
}
|
|
98
92
|
|
|
99
|
-
|
|
93
|
+
} else {
|
|
100
94
|
|
|
101
|
-
|
|
95
|
+
// non-indexed BufferGeometry
|
|
102
96
|
|
|
103
|
-
|
|
104
|
-
normal.fromBufferAttribute( normalAttribute, i );
|
|
97
|
+
for ( i = 0; i < positionAttribute.count; i ++ ) {
|
|
105
98
|
|
|
106
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
122
|
+
// second, clip the geometry so that it doesn't extend out from the projector
|
|
127
123
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
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
|
-
|
|
131
|
+
// third, generate final vertices, normals and uvs
|
|
136
132
|
|
|
137
|
-
|
|
133
|
+
for ( i = 0; i < decalVertices.length; i ++ ) {
|
|
138
134
|
|
|
139
|
-
|
|
135
|
+
var decalVertex = decalVertices[ i ];
|
|
140
136
|
|
|
141
|
-
|
|
137
|
+
// create texture coordinates (we are still in projector space)
|
|
142
138
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
139
|
+
uvs.push(
|
|
140
|
+
0.5 + ( decalVertex.position.x / size.x ),
|
|
141
|
+
0.5 + ( decalVertex.position.y / size.y )
|
|
142
|
+
);
|
|
147
143
|
|
|
148
|
-
|
|
144
|
+
// transform the vertex back to world space
|
|
149
145
|
|
|
150
|
-
|
|
146
|
+
decalVertex.position.applyMatrix4( projectorMatrix );
|
|
151
147
|
|
|
152
|
-
|
|
148
|
+
// now create vertex and normal buffer data
|
|
153
149
|
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
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
|
-
|
|
157
|
+
function pushDecalVertex( decalVertices, vertex, normal ) {
|
|
173
158
|
|
|
174
|
-
|
|
159
|
+
// transform the vertex to world space, then to projector space
|
|
175
160
|
|
|
176
|
-
|
|
161
|
+
vertex.applyMatrix4( mesh.matrixWorld );
|
|
162
|
+
vertex.applyMatrix4( projectorMatrixInverse );
|
|
177
163
|
|
|
178
|
-
|
|
179
|
-
// which consists of three consecutive 'DecalVertex' objects
|
|
164
|
+
normal.transformDirection( mesh.matrixWorld );
|
|
180
165
|
|
|
181
|
-
|
|
166
|
+
decalVertices.push( new THREE.DecalVertex( vertex.clone(), normal.clone() ) );
|
|
182
167
|
|
|
183
|
-
|
|
184
|
-
var nV1, nV2, nV3, nV4;
|
|
168
|
+
}
|
|
185
169
|
|
|
186
|
-
|
|
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
|
-
|
|
191
|
-
v2Out = d2 > 0;
|
|
192
|
-
v3Out = d3 > 0;
|
|
172
|
+
var outVertices = [];
|
|
193
173
|
|
|
194
|
-
|
|
174
|
+
var s = 0.5 * Math.abs( size.dot( plane ) );
|
|
195
175
|
|
|
196
|
-
|
|
176
|
+
// a single iteration clips one face,
|
|
177
|
+
// which consists of three consecutive 'DecalVertex' objects
|
|
197
178
|
|
|
198
|
-
|
|
179
|
+
for ( var i = 0; i < inVertices.length; i += 3 ) {
|
|
199
180
|
|
|
200
|
-
|
|
181
|
+
var v1Out, v2Out, v3Out, total = 0;
|
|
182
|
+
var nV1, nV2, nV3, nV4;
|
|
201
183
|
|
|
202
|
-
|
|
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
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
|
|
194
|
+
total = ( v1Out ? 1 : 0 ) + ( v2Out ? 1 : 0 ) + ( v3Out ? 1 : 0 );
|
|
212
195
|
|
|
213
|
-
|
|
196
|
+
switch ( total ) {
|
|
214
197
|
|
|
215
|
-
|
|
198
|
+
case 0: {
|
|
216
199
|
|
|
217
|
-
|
|
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
|
-
|
|
207
|
+
}
|
|
225
208
|
|
|
226
|
-
|
|
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
|
-
|
|
232
|
-
outVertices.push( nV2.clone() );
|
|
233
|
-
outVertices.push( nV1.clone() );
|
|
211
|
+
// one vertex lies outside of the plane, perform clipping
|
|
234
212
|
|
|
235
|
-
|
|
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
|
-
|
|
220
|
+
}
|
|
243
221
|
|
|
244
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
// two vertices lies outside of the plane, perform clipping
|
|
240
|
+
if ( v3Out ) {
|
|
266
241
|
|
|
267
|
-
|
|
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
|
-
|
|
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
|
-
|
|
253
|
+
outVertices.push( nV4 );
|
|
254
|
+
outVertices.push( nV3.clone() );
|
|
255
|
+
outVertices.push( nV2.clone() );
|
|
279
256
|
|
|
280
|
-
|
|
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
|
-
|
|
261
|
+
case 2: {
|
|
290
262
|
|
|
291
|
-
|
|
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
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
// the entire face lies outside of the plane, so let's discard the corresponding vertices
|
|
276
|
+
if ( ! v2Out ) {
|
|
307
277
|
|
|
308
|
-
|
|
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
|
-
|
|
296
|
+
}
|
|
317
297
|
|
|
318
|
-
|
|
298
|
+
break;
|
|
319
299
|
|
|
320
|
-
|
|
300
|
+
}
|
|
321
301
|
|
|
322
|
-
|
|
323
|
-
var d1 = v1.position.dot( p ) - s;
|
|
302
|
+
case 3: {
|
|
324
303
|
|
|
325
|
-
|
|
304
|
+
// the entire face lies outside of the plane, so let's discard the corresponding vertices
|
|
326
305
|
|
|
327
|
-
|
|
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
|
-
|
|
341
|
-
// intersectpoint.value = a.value + s * ( b.value - a.value );
|
|
308
|
+
}
|
|
342
309
|
|
|
343
|
-
|
|
310
|
+
}
|
|
344
311
|
|
|
345
312
|
}
|
|
346
313
|
|
|
314
|
+
return outVertices;
|
|
315
|
+
|
|
347
316
|
}
|
|
348
317
|
|
|
349
|
-
|
|
350
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
357
|
-
this.normal = normal;
|
|
341
|
+
return v;
|
|
358
342
|
|
|
359
343
|
}
|
|
360
344
|
|
|
361
|
-
|
|
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
|
-
|
|
354
|
+
this.position = position;
|
|
355
|
+
this.normal = normal;
|
|
364
356
|
|
|
365
|
-
|
|
357
|
+
};
|
|
366
358
|
|
|
367
|
-
|
|
359
|
+
THREE.DecalVertex.prototype.clone = function () {
|
|
368
360
|
|
|
369
|
-
|
|
361
|
+
return new this.constructor( this.position.clone(), this.normal.clone() );
|
|
370
362
|
|
|
371
|
-
}
|
|
363
|
+
};
|