@@ -40,49 +40,121 @@ const simpleWallType = new CLAY.SimpleWallType(model);
4040
4141const wall1 = simpleWallType . addInstance ( ) ;
4242world . scene . three . add ( ...wall1 . meshes ) ;
43- wall1 . startPoint = new THREE . Vector2 ( 1 , 1 ) ;
44- wall1 . endPoint = new THREE . Vector2 ( 3 , 0 ) ;
43+ wall1 . startPoint = new THREE . Vector2 ( 0 , 0 ) ;
44+ wall1 . endPoint = new THREE . Vector2 ( 1 , 0 ) ;
4545wall1 . update ( true ) ;
4646wall1 . meshes [ 0 ] . setColorAt ( 0 , new THREE . Color ( 1 , 0 , 0 ) ) ;
4747
4848const wall2 = simpleWallType . addInstance ( ) ;
4949world . scene . three . add ( ...wall2 . meshes ) ;
50- wall2 . startPoint = new THREE . Vector2 ( 0 , - 2 ) ;
51- wall2 . endPoint = new THREE . Vector2 ( 0 , 3 ) ;
50+ wall2 . startPoint = new THREE . Vector2 ( 0 , 0 ) ;
51+ wall2 . endPoint = new THREE . Vector2 ( 0 , 1 ) ;
5252wall2 . update ( true ) ;
5353
5454site . children . add ( wall1 . attributes . expressID ) ;
5555site . children . add ( wall2 . attributes . expressID ) ;
5656
57- simpleWallType . addCorner ( {
58- wall1,
59- wall2,
60- to : "interior" ,
61- cut : "interior" ,
62- cutDirection : "interior" ,
63- priority : "end" ,
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+ }
64125} ) ;
65126
66- simpleWallType . addCorner ( {
67- wall1 : wall2 ,
68- wall2 : wall1 ,
69- to : "interior" ,
70- cut : "exterior" ,
71- cutDirection : "interior" ,
72- priority : "start" ,
73- } ) ;
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+ // });
74146
75147await simpleWallType . updateCorners ( ) ;
76148
77149world . camera . controls . fitToSphere ( wall1 . meshes [ 0 ] , false ) ;
78150
79- const simpleOpeningType = new CLAY . SimpleOpeningType ( model ) ;
80- const opening = simpleOpeningType . addInstance ( ) ;
151+ // const simpleOpeningType = new CLAY.SimpleOpeningType(model);
152+ // const opening = simpleOpeningType.addInstance();
81153// scene.add(...opening.meshes);
82154// console.log(simpleOpeningType);
83155
84- await wall1 . addSubtraction ( opening , true ) ;
85- wall1 . update ( true ) ;
156+ // await wall1.addSubtraction(opening, true);
157+ // wall1.update(true);
86158
87159// Stats
88160
@@ -111,6 +183,7 @@ const panel = BUI.Component.create<BUI.PanelSection>(() => {
111183 ) => {
112184 wall1 . startPoint . x = event . target . value ;
113185 wall1 . update ( true ) ;
186+ updatePlane ( ) ;
114187 simpleWallType . updateCorners ( ) ;
115188 } } "> </ bim-number-input >
116189
@@ -119,6 +192,7 @@ const panel = BUI.Component.create<BUI.PanelSection>(() => {
119192 ) => {
120193 wall1 . startPoint . y = event . target . value ;
121194 wall1 . update ( true ) ;
195+ updatePlane ( ) ;
122196 simpleWallType . updateCorners ( ) ;
123197 } } "> </ bim-number-input >
124198
@@ -131,6 +205,7 @@ const panel = BUI.Component.create<BUI.PanelSection>(() => {
131205 ) => {
132206 wall1 . endPoint . x = event . target . value ;
133207 wall1 . update ( true ) ;
208+ updatePlane ( ) ;
134209 simpleWallType . updateCorners ( ) ;
135210 } } "> </ bim-number-input >
136211
@@ -139,6 +214,7 @@ const panel = BUI.Component.create<BUI.PanelSection>(() => {
139214 ) => {
140215 wall1 . endPoint . y = event . target . value ;
141216 wall1 . update ( true ) ;
217+ updatePlane ( ) ;
142218 simpleWallType . updateCorners ( ) ;
143219 } } "> </ bim-number-input >
144220
@@ -152,6 +228,7 @@ const panel = BUI.Component.create<BUI.PanelSection>(() => {
152228 opening . update ( ) ;
153229 wall1 . elevation = event . target . value ;
154230 wall1 . update ( true ) ;
231+ updatePlane ( ) ;
155232 simpleWallType . updateCorners ( ) ;
156233 } } "> </ bim-number-input >
157234
0 commit comments