@@ -29,6 +29,11 @@ world.scene.three.background = null;
2929const grids = components . get ( OBC . Grids ) ;
3030grids . create ( world ) ;
3131
32+ const axis = new THREE . AxesHelper ( ) ;
33+ axis . material . depthTest = false ;
34+ axis . material . transparent = true ;
35+ world . scene . three . add ( axis ) ;
36+
3237const model = new CLAY . Model ( ) ;
3338model . wasm = { path :
"https://unpkg.com/[email protected] /" , absolute :
true } ; 3439await model . init ( ) ;
@@ -40,121 +45,23 @@ const simpleWallType = new CLAY.SimpleWallType(model);
4045
4146const wall1 = simpleWallType . addInstance ( ) ;
4247world . scene . three . add ( ...wall1 . meshes ) ;
43- wall1 . startPoint = new THREE . Vector2 ( 0 , 0 ) ;
44- wall1 . endPoint = new THREE . Vector2 ( 1 , 0 ) ;
48+ // wall1.startPoint = new THREE.Vector2(0, 0);
49+ // wall1.endPoint = new THREE.Vector2(1, 0);
4550wall1 . update ( true ) ;
46- wall1 . meshes [ 0 ] . setColorAt ( 0 , new THREE . Color ( 1 , 0 , 0 ) ) ;
47-
48- const wall2 = simpleWallType . addInstance ( ) ;
49- world . scene . three . add ( ...wall2 . meshes ) ;
50- wall2 . startPoint = new THREE . Vector2 ( 0 , 0 ) ;
51- wall2 . endPoint = new THREE . Vector2 ( 0 , 1 ) ;
52- wall2 . update ( true ) ;
51+ // wall1.meshes[0].setColorAt(0, new THREE.Color(1, 0, 0));
5352
5453site . children . add ( wall1 . attributes . expressID ) ;
55- site . children . add ( wall2 . attributes . expressID ) ;
56-
57- const halfSpace = new CLAY . HalfSpace ( model ) ;
58- wall1 . body . addSubtraction ( halfSpace ) ;
59-
60- const mesh = new THREE . Mesh (
61- new THREE . PlaneGeometry ( 2 , 2 , 2 ) ,
62- new THREE . MeshLambertMaterial ( {
63- color : "blue" ,
64- transparent : true ,
65- opacity : 0.6 ,
66- side : 2 ,
67- } ) ,
68- ) ;
69-
70- world . scene . three . add ( mesh ) ;
71-
72- mesh . position . set ( 1 , 1 , 0 ) ;
73- mesh . lookAt ( 0.5 , 0 , 0.5 ) ;
74-
75- const offset = 0.5 ;
76-
77- function updatePlane ( ) {
78- const p = CLAY . MathUtils . toThreeCoords ( wall1 . midPoint ) ;
79- const d = CLAY . MathUtils . toThreeCoords ( wall1 . direction ) ;
80- d . multiplyScalar ( offset ) ;
81- p . add ( d ) ;
82- mesh . position . copy ( p ) ;
83- const start = CLAY . MathUtils . toThreeCoords ( wall1 . startPoint3D ) ;
84- mesh . lookAt ( start ) ;
85- }
86-
87- // updatePlane();
88-
89- // halfSpace.rotation.y = Math.PI / 2;
90- // halfSpace.position.x = 0.5;
91-
92- console . log ( halfSpace . rotation ) ;
93- console . log ( mesh . rotation ) ;
94-
95- // halfSpace.position.copy(CLAY.MathUtils.toIfcCoords(mesh.position));
96- // halfSpace.rotation.copy(CLAY.MathUtils.toIfcCoords(mesh.rotation));
97-
98- function updateHalfSpace ( ) {
99- halfSpace . rotation . x = mesh . rotation . x - Math . PI / 2 ;
100- halfSpace . rotation . y = - mesh . rotation . y ;
101- halfSpace . rotation . z = mesh . rotation . z - Math . PI / 2 ;
102-
103- const midPoint = CLAY . MathUtils . toThreeCoords ( wall1 . midPoint ) ;
104- const position = mesh . position . clone ( ) . sub ( midPoint ) ;
105- const truePosition = CLAY . MathUtils . toIfcCoords ( position ) ;
106- halfSpace . position . copy ( truePosition ) ;
107-
108- halfSpace . update ( ) ;
109- wall1 . update ( true ) ;
110- }
111-
112- window . addEventListener ( "keydown" , ( e ) => {
113- if ( e . code === "KeyA" ) {
114- mesh . rotation . x += ( Math . PI / 180 ) * 5 ;
115- updateHalfSpace ( ) ;
116- }
117- if ( e . code === "KeyS" ) {
118- mesh . rotation . y += ( Math . PI / 180 ) * 5 ;
119- updateHalfSpace ( ) ;
120- }
121- if ( e . code === "KeyD" ) {
122- mesh . rotation . z += ( Math . PI / 180 ) * 5 ;
123- updateHalfSpace ( ) ;
124- }
125- } ) ;
126-
127- updateHalfSpace ( ) ;
128-
129- // simpleWallType.addCorner({
130- // wall1,
131- // wall2,
132- // to: "interior",
133- // cut: "interior",
134- // cutDirection: "interior",
135- // priority: "end",
136- // });
137- //
138- // simpleWallType.addCorner({
139- // wall1: wall2,
140- // wall2: wall1,
141- // to: "interior",
142- // cut: "exterior",
143- // cutDirection: "interior",
144- // priority: "start",
145- // });
146-
147- await simpleWallType . updateCorners ( ) ;
14854
14955world . camera . controls . fitToSphere ( wall1 . meshes [ 0 ] , false ) ;
15056
151- // const simpleOpeningType = new CLAY.SimpleOpeningType(model);
152- // const opening = simpleOpeningType.addInstance();
153- // scene.add(...opening.meshes);
154- // console.log(simpleOpeningType);
57+ const simpleOpeningType = new CLAY . SimpleOpeningType ( model ) ;
58+ const opening = simpleOpeningType . addInstance ( ) ;
59+ world . scene . three . add ( ...opening . meshes ) ;
60+ console . log ( simpleOpeningType ) ;
61+ opening . transformation . position . x += 1 ;
15562
156- // await wall1.addSubtraction(opening, true);
157- // wall1.update(true);
63+ await wall1 . addSubtraction ( opening , true ) ;
64+ wall1 . update ( true ) ;
15865
15966// Stats
16067
@@ -183,17 +90,15 @@ const panel = BUI.Component.create<BUI.PanelSection>(() => {
18390 ) => {
18491 wall1 . startPoint . x = event . target . value ;
18592 wall1 . update ( true ) ;
186- updatePlane ( ) ;
187- simpleWallType . updateCorners ( ) ;
93+ // simpleWallType.updateCorners();
18894 } } "> </ bim-number-input >
18995
190- < bim-number-input slider step ="0.1 " label ="Start Y " vertical ="true " value ="${ wall1 . startPoint . y } " @change ="${ (
96+ < bim-number-input slider step ="0.1 " label ="Start Z " vertical ="true " value ="${ wall1 . startPoint . y } " @change ="${ (
19197 event : any ,
19298 ) => {
19399 wall1 . startPoint . y = event . target . value ;
194100 wall1 . update ( true ) ;
195- updatePlane ( ) ;
196- simpleWallType . updateCorners ( ) ;
101+ // simpleWallType.updateCorners();
197102 } } "> </ bim-number-input >
198103
199104 </ div >
@@ -205,17 +110,15 @@ const panel = BUI.Component.create<BUI.PanelSection>(() => {
205110 ) => {
206111 wall1 . endPoint . x = event . target . value ;
207112 wall1 . update ( true ) ;
208- updatePlane ( ) ;
209- simpleWallType . updateCorners ( ) ;
113+ // simpleWallType.updateCorners();
210114 } } "> </ bim-number-input >
211115
212- < bim-number-input slider step ="0.1 " label ="End Y " vertical ="true " value ="${ wall1 . endPoint . y } " @change ="${ (
116+ < bim-number-input slider step ="0.1 " label ="End Z " vertical ="true " value ="${ wall1 . endPoint . y } " @change ="${ (
213117 event : any ,
214118 ) => {
215119 wall1 . endPoint . y = event . target . value ;
216120 wall1 . update ( true ) ;
217- updatePlane ( ) ;
218- simpleWallType . updateCorners ( ) ;
121+ // simpleWallType.updateCorners();
219122 } } "> </ bim-number-input >
220123
221124
@@ -224,38 +127,32 @@ const panel = BUI.Component.create<BUI.PanelSection>(() => {
224127 < bim-number-input slider step ="0.05 " label ="Elevation " value ="${ wall1 . elevation } " @change ="${ (
225128 event : any ,
226129 ) => {
227- opening . position . z = event . target . value ;
228- opening . update ( ) ;
229- wall1 . elevation = event . target . value ;
130+ wall1 . transformation . position . y = event . target . value ;
230131 wall1 . update ( true ) ;
231- updatePlane ( ) ;
232- simpleWallType . updateCorners ( ) ;
233132 } } "> </ bim-number-input >
234133
235134 < bim-number-input slider step ="0.01 " label ="Offset " value ="${ wall1 . offset } " @change ="${ (
236135 event : any ,
237136 ) => {
238137 wall1 . offset = event . target . value ;
239138 wall1 . update ( true ) ;
240- wall2 . offset = event . target . value ;
241- wall2 . update ( true ) ;
242- simpleWallType . updateCorners ( ) ;
139+ // simpleWallType.updateCorners();
243140 } } "> </ bim-number-input >
244141
245142 < bim-number-input slider step ="0.05 " label ="Thickness " value ="${ simpleWallType . width } " @change ="${ (
246143 event : any ,
247144 ) => {
248145 simpleWallType . width = event . target . value ;
249146 simpleWallType . update ( true ) ;
250- simpleWallType . updateCorners ( ) ;
147+ // simpleWallType.updateCorners();
251148 } } "> </ bim-number-input >
252149
253150 < bim-number-input slider step ="0.05 " label ="Height " value ="${ wall1 . height } " @change ="${ (
254151 event : any ,
255152 ) => {
256153 wall1 . height = event . target . value ;
257154 wall1 . update ( true ) ;
258- simpleWallType . updateCorners ( ) ;
155+ // simpleWallType.updateCorners();
259156 } } "> </ bim-number-input >
260157
261158 </ bim-panel-section >
0 commit comments