Commits

Anonymous committed 4561210

refactor: move particle system into its own baseModel object

Comments (0)

Files changed (1)

     display3d.setVideo(video.viewReality.camera, video.viewReality.scene);
 
     var generateParticleSystem = function(color, width,height,depth) {
+        var base = createBaseModel();
         var particleCount = 300;
         var particles = new THREE.Geometry();
         var pMaterial = new THREE.ParticleBasicMaterial({
         // create the particle system
         var particleSystem = new THREE.ParticleSystem( particles, pMaterial);
         particleSystem.sortParticles = true;
-        return particleSystem;
+        base.model.add(particleSystem);
+        return base;
     }
 
 
         }
     }
 
-    var createFrameModel = function(color) {
+    var createFrameModel = function() {
         var components = generateFrameComponents(settings.portalSize, settings.frameSize, settings.portalDepth,0xd2b48c, false );
         var selectorComponents = generateFrameComponents( settings.portalSize*1.3, settings.frameSize/2, 0.25, 0xFFFF00, true );
         var button = new THREE.Object3D();
         that.model.add(back);
         that.model.add(hitbox);
         that.model.add(button);
-        that.model.add(generateParticleSystem(color, settings.portalSize,settings.portalSize,settings.portalSize));
         that.hitbox = hitbox;
 
         return that;
         var that = {};
         that.id = id;
         that.isOpen = false;
-        that.frame = createFrameModel(warpHoleColors[id]);
+        that.frame = createFrameModel();
+        that.particles = generateParticleSystem(warpHoleColors[id], portalWidth, portalHeight, settings.portalDepth);
         that.occluder = createOccluderModel();
         that.mapContainer = createBaseModel();
         that.playerContainer = createBaseModel();
             that.frame.transform(matrix);
             that.playerContainer.transform(matrix);
             that.occluder.transform(matrix);
+            that.particles.transform(matrix);
         }
 
         that.intersectsRay = function(raycaster) {
             scene.add(that.frame.model);
             scene.add(that.mapContainer.model);
             scene.add(that.playerContainer.model);
+            scene.add(that.particles.model);
             occlusionScene.add(that.occluder.model);
         }
 
             scene.remove(that.frame.model);
             scene.remove(that.mapContainer.model);
             scene.remove(that.playerContainer.model);
+            scene.remove(that.particles.model);
             occlusionScene.remove(that.occluder.model);
         }