You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+100-2Lines changed: 100 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -150,7 +150,9 @@ But for completeness, here is an example where we both shorten the previous scen
150
150
Adding backgrounds ain't all that hard, once you have an overweiv of whats needed!
151
151
152
152
First of all, make sure there is an actual existing file containing the code for your background.
153
-
If you want to render your background on a canvas the content should be something like:
153
+
If you want to render your background on a canvas the content should be something like the example below.
154
+
Note that to actuall work with the content, you will probably want to be able to see it first.
155
+
To make the content visible, you should go through the steps with adding it the scene and in graph.json, as described below the example.
154
156
155
157
```js
156
158
(function(global) {
@@ -205,11 +207,107 @@ If you want to render your background on a canvas the content should be somethin
205
207
})(this);
206
208
```
207
209
210
+
Once you've decided on a name for the background-class, you should add it to the graph.json (`.../demo_repository/res/graph.json`).
211
+
It has to be added both as a separate node, and as an input to the scene you wish to use it in.
212
+
Example:
213
+
214
+
```json
215
+
[
216
+
// loads of graph.json content
217
+
// ...
218
+
// },
219
+
{
220
+
"id": "the_scene",
221
+
"type": "the_scene",
222
+
"connected": {
223
+
"param_name": "background_class_name.render"
224
+
}
225
+
},
226
+
// more graph.js
227
+
// ...
228
+
// },
229
+
{
230
+
"id": "background_class_name",
231
+
"type": "background_class_name"
232
+
}
233
+
// possibly more graph.json, but you've just added this, right? =P
234
+
]
235
+
```
236
+
237
+
Note the `.render` after the backgrounds class name in the `connected` section!
238
+
239
+
Finally, you need to add the new background to your scene.
240
+
This recquires a couple of things.
241
+
242
+
First, you need to take make sure the background class is declared as an input in your constructors call to super.
243
+
Then, in your constructor, you need to define the mesh your background class will draw on, its size and location, and add it to your scene.
244
+
At this point you should be mindfull of whether you make your background render from both sides, or only the front or back side.
245
+
If you make a background in the form of a "sky box" that engulfs the scene in front of the camera, you'll likely want to set the drawing side to `side: THREE.BackSide`.
246
+
(This is handy if you have a lot of camera movement and can't guarantee that that anything in your scene wil neccessarily be infront of any given plane that you might have wanted to use as a background.)
247
+
This should prevent your background from loading in front of th
248
+
After that, in your scenes `update`-function, you need to ensure that your background also gets updated.
249
+
That is done by setting assigning materials' (mesh you declared in the constructors') map to the background-input.
250
+
Note that you at this point probably should also set the flag for that it needs updating.
251
+
Lastly, you should be aware that in regards to the camera and general movement in the scene, the backgound can be considered just like any other object.
252
+
This implies that for a scene with a lot of camera movement, you can both make the background an object that moves together with the camera and appears static, or you can make it rotate wildly.
0 commit comments