Commits

Anonymous committed 3b26320

new type of warphole: image

  • Participants
  • Parent commits cecdf3e

Comments (0)

Files changed (2)

File augmented.js

         return result;
     }
 
+    var createImageFrameModel = 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();
+        button.add( selectorComponents.top );
+        button.add( selectorComponents.bottom );
+        button.add( selectorComponents.right );
+        button.add( selectorComponents.left );
+        button.position.set(
+            0,
+            0,
+            -1);
+        button.name = "button";
+        button.visible = false;
+
+        var img = new THREE.MeshBasicMaterial({ //CHANGED to MeshBasicMaterial
+            map:THREE.ImageUtils.loadTexture('overafrica.jpg')
+        });
+        img.map.needsUpdate = true; //ADDED
+
+        var back = new THREE.Mesh(
+            new THREE.PlaneGeometry( settings.portalSize+2, settings.portalSize+2 ),
+            img
+        );
+        back.position.set(0,0,settings.portalDepth+0.1);
+
+        var hitbox = new THREE.Mesh(
+            new THREE.PlaneGeometry( settings.portalSize, settings.portalSize ),
+            new THREE.MeshLambertMaterial( {transparent:true, opacity:0.0, color:0xFFFFFF, side:THREE.DoubleSide} ) 
+        );
+        hitbox.position.set(0,0,0);
+
+        var that = createBaseModel();
+        that.model.add(components.top);
+        that.model.add(components.bottom);
+        that.model.add(components.left);
+        that.model.add(components.right);
+        that.model.add(back);
+        that.model.add(hitbox);
+        that.model.add(button);
+        that.hitbox = hitbox;
+
+        return that;
+    }
+
     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 );
         return that;
     }
 
+    var createWarpHole = function(portalWidth, portalHeight, id) {
+        if( id === 32 ) {
+            return createWarpImage(portalWidth, portalHeight, id);
+        }
+        else {
+            return createRealWarpHole(portalWidth, portalHeight, id);
+        }
+    }
+
+    var createWarpImage = function(portalWidth,portalHeight,id) {
+        var that = {};
+        that.id = id;
+        that.frame = createImageFrameModel();
+        that.occluder = createOccluderModel();
+
+        that.transform = function(matrix) {
+            that.frame.transform(matrix);
+            that.occluder.transform(matrix);
+        }
+
+        that.intersectsRay = function(raycaster) {
+            var hits = raycaster.intersectObject( that.frame.hitbox );
+            return(hits.length > 0); 
+        }
+
+        that.setHighlight = function( state ) {
+            var obj = that.frame.model.getChildByName("button",true);
+            obj.traverse( function(obj) { obj.visible = state; } );
+        }
+
+        var positionPlayer = function() {
+        }
+
+        var insertPlayer = function() {
+        }
+
+        var insertItem = function(item) {
+        }
+
+        var extractItem = function() {
+        }
+
+        var playerIsInChamber = function() {
+            return false;
+        }
+
+        var addPlayer = function() {
+        }
+
+        var removePlayer = function() {
+        }
+
+        that.update = function(time) {
+        }
+
+        that.close = function() {
+        }
+
+        that.containsPlayerMapPosition = function() {
+            return false;
+        }
 
-    var createWarpHole = function(portalWidth,portalHeight,id) {
+        that.addToScene = function( scene, occlusionScene ) {
+            scene.add(that.frame.model);
+            occlusionScene.add(that.occluder.model);
+        }
+
+        that.removeFromScene = function( scene, occlusionScene ) {
+            scene.remove(that.frame.model);
+            occlusionScene.remove(that.occluder.model);
+        }
+
+        that.insertPlayer = insertPlayer;
+        that.removePlayer = removePlayer;
+        that.insertItem = insertItem;
+        that.extractItem = extractItem;
+
+        return that;
+    };
+
+    var createRealWarpHole = function(portalWidth,portalHeight,id) {
         var that = {};
         that.id = id;
         that.frame = createFrameModel();
             return mapObject.containsPoint(player.mapPosition);
         }
 
+        that.addToScene = function( scene, occlusionScene ) {
+            scene.add(that.frame.model);
+            scene.add(that.mapContainer.model);
+            scene.add(that.playerContainer.model);
+            occlusionScene.add(that.occluder.model);
+        }
+
+        that.removeFromScene = function( scene, occlusionScene ) {
+            scene.remove(that.frame.model);
+            scene.remove(that.mapContainer.model);
+            scene.remove(that.playerContainer.model);
+            occlusionScene.remove(that.occluder.model);
+        }
+
         that.insertPlayer = insertPlayer;
         that.removePlayer = removePlayer;
         that.insertItem = insertItem;
 
         var addWarpHole = function(warpHole) {
             warpHoles[warpHole.id] = warpHole;
-            scene.add(warpHole.frame.model);
-            scene.add(warpHole.mapContainer.model);
-            scene.add(warpHole.playerContainer.model);
-            occlusionScene.add(warpHole.occluder.model);
+            warpHole.addToScene(scene, occlusionScene);
         }
 
         var removeWarpHole = function(warpHole) {
             warpHole.close();
-            scene.remove(warpHole.frame.model);
-            scene.remove(warpHole.mapContainer.model);
-            scene.remove(warpHole.playerContainer.model);
-            occlusionScene.remove(warpHole.occluder.model);
+            warpHole.removeFromScene(scene, occlusionScene);
             delete warpHoles[warpHole.id];
         }
 

File overafrica.jpg

Added
New image