-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy paththreex.htmlmultiplemixer.js
60 lines (44 loc) · 1.3 KB
/
threex.htmlmultiplemixer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Special wrapper to handle multiple THREEx.HtmlMixer.Context for a single WebglRenderer
* * especially useful when the webglrenderer is doing scissor/viewport like multiviewport editors
*/
var THREEx = THREEx || {}
THREEx.HtmlMultipleMixer = {}
/**
* Multiple context handled as one, thus able to handle multi viewport
*/
THREEx.HtmlMultipleMixer.Context = function(){
// store all context
var contexts = []
this.contexts = contexts
// update all context
this.update = function(){
contexts.forEach(function(context){
context.update();
})
}
}
THREEx.HtmlMultipleMixer.Plane = function(multipleMixerContext, domElement, opts){
opts = opts || {}
opts = JSON.parse(JSON.stringify(opts))
var contexts = multipleMixerContext.contexts
var planes = []
this.planes = planes
var mixerContext= contexts[0]
var plane = new THREEx.HtmlMixer.Plane(mixerContext, domElement, opts);
planes.push(plane)
this.object3d = plane.object3d
opts.object3d = this.object3d
for(var i = 1; i < contexts.length; i++){
var mixerContext= contexts[i]
var cloneElement= domElement.cloneNode()
var plane = new THREEx.HtmlMixer.Plane(mixerContext, cloneElement, opts);
planes.push(plane)
}
// update all context
this.update = function(){
planes.forEach(function(plane){
plane.update();
})
}
}