Skip to content

Commit 3982ea6

Browse files
authored
Merge pull request #2091 from wonderunit/sg-object-creation
Objects Creation in Front of camera
2 parents ef24d2d + 0dcef2b commit 3982ea6

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/js/shared/actions/scene-object-creators.js

+9-7
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,14 @@ const createCharacter = (id, camera, room) => {
118118
})
119119
}
120120

121-
const createLight = (id) => {
121+
const createLight = (id, camera, room) => {
122+
let { x, y, z, rotation } = generatePositionAndRotation(camera, room)
122123
return createObject({
123124
id,
124125
type: 'light',
125126

126-
x: 0, y: 0, z: 2,
127-
rotation: 0, tilt: 0, roll: 0,
127+
x: x, y: y, z: 2,
128+
rotation: rotation, tilt: 0, roll: 0,
128129

129130
intensity: 0.8,
130131
visible: true,
@@ -135,16 +136,17 @@ const createLight = (id) => {
135136
})
136137
}
137138

138-
const createVolume = (id) => {
139+
const createVolume = (id, camera, room) => {
140+
let { x, y, z, rotation } = generatePositionAndRotation(camera, room)
139141
return createObject({
140142
id,
141143
type: 'volume',
142144

143-
x: 0, y: 2, z: 0,
145+
x: x, y: y, z: z,
144146

145147
width: 5, height: 5, depth: 5,
146148

147-
rotation: 0,
149+
rotation: rotation,
148150

149151
visible: true,
150152
opacity: 0.3,
@@ -157,7 +159,7 @@ const createVolume = (id) => {
157159

158160
const createImage = (id, camera, room) => {
159161
let { x, y, z, rotation } = generatePositionAndRotation(camera, room)
160-
162+
161163
return createObject({
162164
id,
163165
type: 'image',

src/js/shot-generator/components/Toolbar/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,18 @@ const Toolbar = connect(
136136

137137
const onCreateLightClick = () => {
138138
let id = THREE.Math.generateUUID()
139-
139+
initCamera()
140140
undoGroupStart()
141-
createLight(id)
141+
createLight(id, camera.current, room.visible && roomObject3d)
142142
selectObject(id)
143143
undoGroupEnd()
144144
}
145145

146146
const onCreateVolumeClick = () => {
147147
let id = THREE.Math.generateUUID()
148-
148+
initCamera()
149149
undoGroupStart()
150-
createVolume(id)
150+
createVolume(id, camera.current, room.visible && roomObject3d)
151151
selectObject(id)
152152
undoGroupEnd()
153153
}

0 commit comments

Comments
 (0)