kopia lustrzana https://github.com/backface/turtlestitch
add and improve...
rodzic
695746f34e
commit
75c1774b8f
|
@ -22,11 +22,8 @@
|
|||
|
||||
<script type="text/javascript" src="stitchcode/jquery.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/Filesaver.js"></script>
|
||||
|
||||
<script type="text/javascript" src="stitchcode/three.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/OrbitControls.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/threee/THREE.MeshLine.js"></script>
|
||||
|
||||
<script type="text/javascript" src="stitchcode/turtleShepherd.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/blocks.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/store.js"></script>
|
||||
|
@ -35,7 +32,6 @@
|
|||
<script type="text/javascript" src="stitchcode/gui-cloud.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/cloud.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var world;
|
||||
window.onload = function () {
|
||||
|
|
|
@ -3962,10 +3962,12 @@ SpriteMorph.prototype.bounceOffEdge = function () {
|
|||
|
||||
SpriteMorph.prototype.setRotationX = function (absoluteX) {
|
||||
this.setRotationCenter(new Point(absoluteX, this.yPosition()));
|
||||
alert(absoluteX);
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.setRotationY = function (absoluteY) {
|
||||
this.setRotationCenter(new Point(this.xPosition(), absoluteY));
|
||||
alert(absolutexy);
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.setRotationCenter = function (absoluteCoordinate) {
|
||||
|
|
|
@ -32,19 +32,6 @@ IDE_Morph.prototype.createLogo = function () {
|
|||
this.logo.drawNew();
|
||||
};
|
||||
|
||||
/*
|
||||
IDE_Morph.prototype.init = (function init (oldInit) {
|
||||
return function(isAutoFill) {
|
||||
var retval = oldInit.call(this, isAutoFill);
|
||||
this.currentCategory = 'network';
|
||||
this.maxVisibleNodes = DEFAULT_MAX_VISIBLE_NODES;
|
||||
this.logoURL = 'edgy_logo.png';
|
||||
return retval;
|
||||
}
|
||||
}(IDE_Morph.prototype.init));
|
||||
*/
|
||||
|
||||
|
||||
// Single Sprite mode, no corral and no tabs in the scripting area
|
||||
IDE_Morph.prototype.createCorralBar = nop;
|
||||
IDE_Morph.prototype.createCorral = nop;
|
||||
|
@ -633,7 +620,7 @@ IDE_Morph.prototype.createStatusDisplay = function () {
|
|||
element = new Morph();
|
||||
element.setHeight(1);
|
||||
element.setWidth(this.width());
|
||||
element.setColor(new Color(150, 150, 150));
|
||||
element.setColor(new Color(200, 200, 200));
|
||||
element.newLines = 0.5;
|
||||
element.flush = true;
|
||||
} else {
|
||||
|
@ -701,7 +688,7 @@ IDE_Morph.prototype.createStatusDisplay = function () {
|
|||
space.newLines = 0.5;
|
||||
elements.push(space);
|
||||
|
||||
elements.push('Total Stitches: ');
|
||||
elements.push(' Total Stitches: ');
|
||||
element = new StringMorph();
|
||||
element.update = function () {
|
||||
this.text = (stage.turtleShepherd.getStepCount()).toString()+ " ";
|
||||
|
@ -730,65 +717,71 @@ IDE_Morph.prototype.createStatusDisplay = function () {
|
|||
|
||||
elements.push('-');
|
||||
|
||||
var toogleShowStitchPointsButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
null,
|
||||
function () {
|
||||
stage.renderer.toggleStitchPoints();
|
||||
},
|
||||
'Stitchpoints',
|
||||
function () {
|
||||
return stage.renderer.showingStitchPoints;
|
||||
});
|
||||
toogleShowStitchPointsButton.columns = 4;
|
||||
toogleShowStitchPointsButton.newColumn = 1;
|
||||
elements.push(toogleShowStitchPointsButton);
|
||||
|
||||
/*
|
||||
// Buttons and toggles
|
||||
var toogleShowStitchButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
null,
|
||||
function () {
|
||||
turtleShepherd.toogleShowStitches();
|
||||
stage.reRender();
|
||||
},
|
||||
'Stitches',
|
||||
function () {
|
||||
return turtleShepherd.getShowStitches();
|
||||
});
|
||||
toogleShowStitchButton.columns = 3;
|
||||
toogleShowStitchButton.newColumn = 1;
|
||||
//toogleShowStitchButton.newLines = 1;
|
||||
var toogleShowJumpLinesButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
null,
|
||||
function () {
|
||||
stage.renderer.toggleJumpLines();
|
||||
},
|
||||
'Jumps',
|
||||
function () {
|
||||
return stage.renderer.showingJumpLines;
|
||||
});
|
||||
toogleShowJumpLinesButton.columns = 4;
|
||||
toogleShowJumpLinesButton.newColumn = 2;
|
||||
elements.push(toogleShowJumpLinesButton);
|
||||
|
||||
elements.push(toogleShowStitchButton);
|
||||
var toggleGridButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
null,
|
||||
function () {
|
||||
stage.scene.grid.toggle();
|
||||
},
|
||||
'Grid',
|
||||
function () {
|
||||
return stage.scene.grid.visible;
|
||||
});
|
||||
toggleGridButton.columns = 4;
|
||||
toggleGridButton.newColumn = 3;
|
||||
elements.push(toggleGridButton);
|
||||
|
||||
var toogleShowJumpsButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
null,
|
||||
function () {
|
||||
turtleShepherd.toogleShowJumpStitches();
|
||||
stage.reRender();
|
||||
},
|
||||
'Jump Stitches',
|
||||
function () {
|
||||
return turtleShepherd.getShowJumpStitches();
|
||||
});
|
||||
var toogleTurtleButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
null,
|
||||
function () {
|
||||
stage.renderer.toggleTurtle();
|
||||
},
|
||||
'Turtle',
|
||||
function () {
|
||||
return stage.renderer.showingTurtle;
|
||||
});
|
||||
|
||||
toogleShowJumpsButton.columns = 3;
|
||||
toogleShowJumpsButton.newColumn = 2;
|
||||
//toogleShowJumpsButton.newLines = 2;
|
||||
elements.push(toogleShowJumpsButton);
|
||||
|
||||
var toogleShowGridButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
null,
|
||||
function () {
|
||||
turtleShepherd.toogleShowGrid();
|
||||
stage.reRender();
|
||||
},
|
||||
'Grid',
|
||||
function () {
|
||||
return turtleShepherd.getShowGrid();
|
||||
});
|
||||
//toogleShowGridButton.columns = 3;
|
||||
toogleShowGridButton.newLines = 2;
|
||||
//toogleShowGridButton.newColumn = 1;
|
||||
elements.push(toogleShowGridButton);
|
||||
*/
|
||||
|
||||
var space = new Morph();
|
||||
space.alpha = 0;
|
||||
space.newLines = 1;
|
||||
elements.push(space);
|
||||
toogleTurtleButton.newLines = 2;
|
||||
elements.push(toogleTurtleButton);
|
||||
elements.push('-');
|
||||
|
||||
var resetCameraButton = new PushButtonMorph(
|
||||
null,
|
||||
function () { stage.camera.reset(); },
|
||||
'Reset View'
|
||||
);
|
||||
resetCameraButton.columns = 4;
|
||||
resetCameraButton.newColumn = 2;
|
||||
elements.push(resetCameraButton);
|
||||
|
||||
var toggleTurboButton = new ToggleMorph(
|
||||
'checkbox',
|
||||
|
@ -800,12 +793,13 @@ IDE_Morph.prototype.createStatusDisplay = function () {
|
|||
function () {
|
||||
return stage.isFastTracked;
|
||||
});
|
||||
//toggleTurboButton.columns = 1;
|
||||
//toggleTurboButton.newColumn = 1;
|
||||
toggleTurboButton.newLines = 2;
|
||||
toggleTurboButton.columns = 4;
|
||||
toggleTurboButton.newColumn = 1;
|
||||
elements.push(toggleTurboButton);
|
||||
|
||||
|
||||
|
||||
|
||||
elements.forEach(function(each) { myself.statusDisplay.addElement(each); });
|
||||
};
|
||||
|
||||
|
@ -1347,33 +1341,6 @@ IDE_Morph.prototype.createSpriteBar = function () {
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
// StageMorph user menu
|
||||
|
||||
StageMorph.prototype.userMenu = function () {
|
||||
var ide = this.parentThatIsA(IDE_Morph),
|
||||
menu = new MenuMorph(this),
|
||||
shiftClicked = this.world().currentKey === 16,
|
||||
myself = this;
|
||||
|
||||
if (ide && ide.isAppMode) {
|
||||
// menu.addItem('help', 'nop');
|
||||
return menu;
|
||||
}
|
||||
//menu.addItem("edit", 'edit');
|
||||
menu.addItem("show all", 'showAll');
|
||||
menu.addItem(
|
||||
"pic...",
|
||||
function () {
|
||||
window.open(myself.fullImageClassic().toDataURL());
|
||||
},
|
||||
'open a new window\nwith a picture of the stage'
|
||||
);
|
||||
return menu;
|
||||
};
|
||||
|
||||
|
||||
IDE_Morph.prototype.createCategories = function () {
|
||||
// assumes the logo has already been created
|
||||
var myself = this;
|
||||
|
|
|
@ -7,8 +7,10 @@ SpriteMorph.prototype.init = function(globals) {
|
|||
this.origInit(globals);
|
||||
this.hide();
|
||||
this.lastJumped = false;
|
||||
this.turtle = null;
|
||||
};
|
||||
|
||||
|
||||
SpriteMorph.prototype.addStitch = function(x1, y1, x2, y2) {
|
||||
var stage = this.parentThatIsA(StageMorph),
|
||||
lineMaterial = new THREE.LineDashedMaterial(
|
||||
|
@ -60,6 +62,7 @@ SpriteMorph.prototype.addJumpLine = function(x1, y1, x2, y2) {
|
|||
jumpLine.geometry.vertices = jumpLine.points;
|
||||
jumpLine.geometry.verticesNeedUpdate = true;
|
||||
jumpLine.line = new THREE.Line(jumpLine.geometry, lineMaterial);
|
||||
jumpLine.line.visible = stage.renderer.showingJumpLines;
|
||||
|
||||
stage.myJumpLines.add(jumpLine.line);
|
||||
|
||||
|
@ -68,7 +71,7 @@ SpriteMorph.prototype.addJumpLine = function(x1, y1, x2, y2) {
|
|||
};
|
||||
|
||||
SpriteMorph.prototype.addStitchPoint = function(x1, y1) {
|
||||
var stage = this.parentThatIsA(StageMorph);
|
||||
var stage = this.parentThatIsA(StageMorph);
|
||||
|
||||
var geometry = new THREE.CircleGeometry( 1.5, 4 );
|
||||
geometry.vertices.shift();
|
||||
|
@ -76,6 +79,7 @@ SpriteMorph.prototype.addStitchPoint = function(x1, y1) {
|
|||
var circle = new THREE.Mesh( geometry, material );
|
||||
circle.translateX(x1);
|
||||
circle.translateY(y1);
|
||||
circle.visible = stage.renderer.showingStitchPoints;
|
||||
|
||||
stage.myStitchPoints.add(circle);
|
||||
|
||||
|
@ -87,6 +91,7 @@ SpriteMorph.prototype.origForward = SpriteMorph.prototype.forward;
|
|||
SpriteMorph.prototype.forward = function (steps) {
|
||||
var dest,
|
||||
dist = steps * this.parent.scale || 0;
|
||||
stage = this.parentThatIsA(StageMorph);
|
||||
|
||||
oldx = this.xPosition();
|
||||
oldy = this.yPosition();
|
||||
|
@ -101,8 +106,7 @@ SpriteMorph.prototype.forward = function (steps) {
|
|||
this.setPosition(dest);
|
||||
this.positionTalkBubble();
|
||||
|
||||
|
||||
this.parentThatIsA(StageMorph).turtleShepherd.moveTo(
|
||||
stage.turtleShepherd.moveTo(
|
||||
oldx, oldy,
|
||||
this.xPosition(), this.yPosition(),
|
||||
this.isDown );
|
||||
|
@ -113,12 +117,14 @@ SpriteMorph.prototype.forward = function (steps) {
|
|||
this.addJumpLine(oldx, oldy, this.xPosition(), this.yPosition());
|
||||
}
|
||||
this.addStitchPoint(this.xPosition(), this.yPosition());
|
||||
stage.moveTurtle(this.xPosition(), this.yPosition());
|
||||
|
||||
//this.changed();
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.origGotoXY = SpriteMorph.prototype.gotoXY;
|
||||
SpriteMorph.prototype.gotoXY = function (x, y, justMe) {
|
||||
var stage = this.parentThatIsA(StageMorph);
|
||||
oldx = this.xPosition();
|
||||
oldy = this.yPosition();
|
||||
this.origGotoXY(x, y, justMe);
|
||||
|
@ -130,16 +136,24 @@ SpriteMorph.prototype.gotoXY = function (x, y, justMe) {
|
|||
this.xPosition(), this.yPosition(),
|
||||
this.isDown );
|
||||
|
||||
if (this.isDown)
|
||||
this.addStitch(oldx, oldy, this.xPosition(), this.yPosition());
|
||||
else {
|
||||
this.addJumpLine(oldx, oldy, this.xPosition(), this.yPosition());
|
||||
}
|
||||
this.addStitchPoint(this.xPosition(), this.yPosition());
|
||||
//this.changed();
|
||||
if (this.isDown)
|
||||
this.addStitch(oldx, oldy, this.xPosition(), this.yPosition());
|
||||
else {
|
||||
this.addJumpLine(oldx, oldy, this.xPosition(), this.yPosition());
|
||||
}
|
||||
this.addStitchPoint(this.xPosition(), this.yPosition());
|
||||
stage.moveTurtle(this.xPosition(), this.yPosition());
|
||||
}
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.origSetHeading = SpriteMorph.prototype.setHeading;
|
||||
SpriteMorph.prototype.setHeading = function (degrees) {
|
||||
var stage = this.parentThatIsA(StageMorph);
|
||||
this.origSetHeading(degrees);
|
||||
stage.rotateTurtle(this.heading);
|
||||
};
|
||||
|
||||
|
||||
SpriteMorph.prototype.drawLine = function (start, dest) {};
|
||||
|
||||
SpriteMorph.prototype.origSilentGotoXY = SpriteMorph.prototype.silentGotoXY;
|
||||
|
@ -214,11 +228,11 @@ StageMorph.prototype.init = function (globals) {
|
|||
this.initScene();
|
||||
this.initRenderer();
|
||||
this.initCamera();
|
||||
this.initLights();
|
||||
|
||||
|
||||
this.turtleShepherd = new TurtleShepherd();
|
||||
|
||||
this.scene.grid.draw();
|
||||
|
||||
this.myObjects = new THREE.Object3D();
|
||||
this.myStitchPoints = new THREE.Object3D();
|
||||
this.myStitchLines = new THREE.Object3D();
|
||||
|
@ -228,7 +242,7 @@ StageMorph.prototype.init = function (globals) {
|
|||
this.scene.add(this.myStitchLines);
|
||||
this.scene.add(this.myJumpLines);
|
||||
|
||||
//this.trailsCanvas = this.renderer.domElement;
|
||||
this.initTurtle();
|
||||
};
|
||||
|
||||
StageMorph.prototype.initScene = function () {
|
||||
|
@ -255,6 +269,7 @@ StageMorph.prototype.initScene = function () {
|
|||
this.lines = [];
|
||||
|
||||
limit = this.interval.x * 20
|
||||
|
||||
for (x = -limit / this.interval.x; x <= limit / this.interval.x; x++) {
|
||||
p1 = new THREE.Vector3(x * this.interval.x, -limit, 0);
|
||||
p2 = new THREE.Vector3(x * this.interval.x, limit, 0);
|
||||
|
@ -279,9 +294,9 @@ StageMorph.prototype.initScene = function () {
|
|||
this.lines.push(l);
|
||||
}
|
||||
|
||||
for (y = -limit/10 / this.interval.y; y <= limit/10 / this.interval.y; y++) {
|
||||
p1 = new THREE.Vector3(-limit, y * this.interval.y* 10, 0);
|
||||
p2 = new THREE.Vector3(limit, y * this.interval.y* 10, 0);
|
||||
for (y = -limit/10 / this.interval.y / 10; y <= limit/10 / this.interval.y / 10 ; y++) {
|
||||
p1 = new THREE.Vector3(-limit, y * this.interval.y/ 10, 0);
|
||||
p2 = new THREE.Vector3(limit, y * this.interval.y/ 10, 0);
|
||||
l = myself.scene.addLineFromPointToPointWithColor(p1, p2, color2);
|
||||
l.visible = this.visible;
|
||||
this.lines.push(l);
|
||||
|
@ -304,16 +319,16 @@ StageMorph.prototype.initScene = function () {
|
|||
this.scene.grid.toggle = function () {
|
||||
var myInnerSelf = this;
|
||||
this.visible = !this.visible;
|
||||
this.lines.forEach(function (line){ line.visible = myInnerSelf.visible });
|
||||
this.lines.forEach(function (line){ line.visible = myInnerSelf.visible; });
|
||||
myself.reRender();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
StageMorph.prototype.clearAll = function () {
|
||||
for (var i = this.myObjects.children.length - 1; i >= 0; i--) {
|
||||
/*for (var i = this.myObjects.children.length - 1; i >= 0; i--) {
|
||||
this.myObjects.remove(this.myObjects.children[i]);
|
||||
}
|
||||
}*/
|
||||
for (i = this.myStitchPoints.children.length - 1; i >= 0; i--) {
|
||||
this.myStitchPoints.remove(this.myStitchPoints.children[i]);
|
||||
}
|
||||
|
@ -336,49 +351,43 @@ StageMorph.prototype.initRenderer = function () {
|
|||
});
|
||||
this.renderer.setClearColor(0xffffff, 1);
|
||||
|
||||
if (localStorage) {
|
||||
// ide is not set yet, we're accessing its prototype to circumvent this
|
||||
this.renderer.setClearColor(IDE_Morph.prototype.getSetting('bgcolor'), 1);
|
||||
}
|
||||
|
||||
this.renderer.changed = false;
|
||||
this.renderer.isWireframeMode = false;
|
||||
this.renderer.showingAxes = true;
|
||||
this.renderer.showingStitchPoints = true;
|
||||
this.renderer.showingJumpLines = true;
|
||||
this.renderer.showingTurtle = true;
|
||||
this.renderer.isParallelProjection = true;
|
||||
|
||||
this.renderer.toggleWireframe = function () {
|
||||
|
||||
this.renderer.toggleJumpLines = function () {
|
||||
var myInnerSelf = this;
|
||||
this.isWireframeMode = !this.isWireframeMode;
|
||||
myself.myObjects.children.forEach(function (eachObject) {
|
||||
eachObject.material.wireframe = myInnerSelf.isWireframeMode;
|
||||
this.showingJumpLines = !this.showingJumpLines;
|
||||
myself.myJumpLines.children.forEach(function (eachObject) {
|
||||
eachObject.visible = myInnerSelf.showingJumpLines;
|
||||
});
|
||||
myself.reRender();
|
||||
}
|
||||
};
|
||||
|
||||
this.renderer.toggleAxes = function () {
|
||||
this.renderer.toggleStitchPoints = function () {
|
||||
var myInnerSelf = this;
|
||||
this.showingAxes = !this.showingAxes;
|
||||
|
||||
myself.scene.labels.forEach(function (label){ label.visible = myInnerSelf.showingAxes });
|
||||
myself.scene.axes.forEach(function (line){ line.visible = myInnerSelf.showingAxes });
|
||||
myself.children.forEach(function (morph) {
|
||||
if (morph instanceof SpriteMorph) {
|
||||
morph.beetle.axes.forEach(function (line){ line.visible = myInnerSelf.showingAxes });
|
||||
}
|
||||
})
|
||||
this.showingStitchPoints = !this.showingStitchPoints;
|
||||
myself.myStitchPoints.children.forEach(function (eachObject) {
|
||||
eachObject.visible = myInnerSelf.showingStitchPoints;
|
||||
});
|
||||
myself.reRender();
|
||||
}
|
||||
};
|
||||
|
||||
this.renderer.toggleTurtle = function () {
|
||||
var myInnerSelf = this;
|
||||
this.showingTurtle = !this.showingTurtle;
|
||||
myself.turtle.visible = myInnerSelf.showingTurtle;
|
||||
myself.reRender();
|
||||
};
|
||||
|
||||
this.renderer.toggleParallelProjection = function () {
|
||||
this.isParallelProjection = !this.isParallelProjection;
|
||||
myself.initCamera();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
StageMorph.prototype.render = function () {
|
||||
//this.pointLight.position.copy(this.camera.position); // lights move with the camera
|
||||
//this.directionalLight.position.copy(this.camera.position);
|
||||
this.renderer.render(this.scene, this.camera);
|
||||
};
|
||||
|
||||
|
@ -399,7 +408,7 @@ StageMorph.prototype.initCamera = function () {
|
|||
var myself = this,
|
||||
threeLayer;
|
||||
|
||||
if (this.scene.camera) { this.scene.remove(this.camera) };
|
||||
if (this.scene.camera) { this.scene.remove(this.camera); }
|
||||
|
||||
var createCamera = function () {
|
||||
threeLayer = document.createElement('div');
|
||||
|
@ -425,11 +434,11 @@ StageMorph.prototype.initCamera = function () {
|
|||
myself.camera.zoomIn = function () {
|
||||
this.zoomFactor /= 1.1;
|
||||
this.applyZoom();
|
||||
}
|
||||
};
|
||||
myself.camera.zoomOut = function () {
|
||||
this.zoomFactor *= 1.1;
|
||||
this.applyZoom();
|
||||
}
|
||||
};
|
||||
|
||||
myself.camera.applyZoom = function () {
|
||||
var zoom = myself.camera ? myself.camera.zoomFactor : 82,
|
||||
|
@ -440,12 +449,12 @@ StageMorph.prototype.initCamera = function () {
|
|||
this.top = height / zoom;
|
||||
this.bottom = height / - zoom;
|
||||
this.updateProjectionMatrix();
|
||||
}
|
||||
};
|
||||
|
||||
myself.camera.reset = function () {
|
||||
|
||||
myself.controls = new THREE.OrbitControls(this, threeLayer);
|
||||
myself.controls.addEventListener('change', function (event) { myself.render });
|
||||
myself.controls.addEventListener('change', function (event) { myself.render(); });
|
||||
|
||||
if (myself.renderer.isParallelProjection) {
|
||||
this.zoomFactor = 2;
|
||||
|
@ -458,11 +467,11 @@ StageMorph.prototype.initCamera = function () {
|
|||
|
||||
myself.controls.update();
|
||||
myself.reRender();
|
||||
}
|
||||
};
|
||||
|
||||
myself.camera.fitScene = function () {
|
||||
|
||||
var boundingBox = new THREE.Box3().setFromObject(myself.myObjects),
|
||||
var boundingBox = new THREE.Box3().setFromObject(myself.myStitchLines),
|
||||
boundingSphere = boundingBox.getBoundingSphere(),
|
||||
center = boundingSphere.center,
|
||||
distance = boundingSphere.radius;
|
||||
|
@ -476,24 +485,41 @@ StageMorph.prototype.initCamera = function () {
|
|||
myself.controls.dollyOut(1.2);
|
||||
myself.controls.update();
|
||||
myself.reRender();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
createCamera();
|
||||
this.scene.add(this.camera);
|
||||
this.camera.reset();
|
||||
};
|
||||
|
||||
StageMorph.prototype.initLights = function () {
|
||||
this.directionalLight = new THREE.DirectionalLight(0x4c4c4c, 1);
|
||||
this.directionalLight.position.set(this.camera.position);
|
||||
this.scene.add(this.directionalLight);
|
||||
|
||||
this.pointLight = new THREE.PointLight(0xffffff, 1, 2000);
|
||||
this.pointLight.position.set(this.camera.position);
|
||||
this.scene.add(this.pointLight);
|
||||
StageMorph.prototype.initTurtle = function() {
|
||||
var myself = this;
|
||||
var geometry = new THREE.Geometry();
|
||||
var material = new THREE.MeshBasicMaterial( { color: 0x000000 } );
|
||||
geometry.vertices = [ new THREE.Vector3(10, 0, 0.01),
|
||||
new THREE.Vector3(-8, 8, 0.01),
|
||||
new THREE.Vector3(-8,-8, 0.01),
|
||||
];
|
||||
geometry.faces.push(new THREE.Face3(0, 1, 2));
|
||||
geometry.verticesNeedUpdate = true;
|
||||
this.turtle = new THREE.Mesh( geometry, material );
|
||||
this.turtle.visible = this.renderer.showingTurtle;
|
||||
myself.myObjects.add(this.turtle);
|
||||
};
|
||||
|
||||
StageMorph.prototype.moveTurtle = function(x, y) {
|
||||
this.turtle.position.x = x;
|
||||
this.turtle.position.y = y;
|
||||
};
|
||||
|
||||
StageMorph.prototype.rotateTurtle = function(h) {
|
||||
this.turtle.rotation.z = (90 -h) * Math.PI / 180;
|
||||
this.renderer.changed = true;
|
||||
};
|
||||
|
||||
|
||||
|
||||
StageMorph.prototype.originalStep = StageMorph.prototype.step;
|
||||
StageMorph.prototype.step = function () {
|
||||
this.originalStep();
|
||||
|
|
Ładowanie…
Reference in New Issue