Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ShallowWaterDemo.as and related files (includding litools package and some asset files). #5

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added embeds/envMap/sky_negX.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added embeds/envMap/sky_negY.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added embeds/envMap/sky_negZ.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added embeds/envMap/sky_posX.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added embeds/envMap/sky_posY.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added embeds/envMap/sky_posZ.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added embeds/li_swf_assets/fractaltree/assets.fla
Binary file not shown.
Binary file added embeds/li_swf_assets/fractaltree/assets.swf
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file added embeds/w_normalmap.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added embeds/water2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/AlphaMapTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ package
var material : BitmapMaterial = new BitmapMaterial(new Albedo().bitmapData);
// material.normalMap = new Normals().bitmapData;
material.ambientColor = 0x080820;
material.ambient = 1;
// material.transparent = true;
material.diffuseMethod.alphaThreshold = .25;
material.alphaThreshold = .5;
// material.transparent = true;
// material.specularMethod = null;

Expand Down
4 changes: 3 additions & 1 deletion src/AnimBlendTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,17 @@ package
var material : BitmapMaterial = new BitmapMaterial(new Teeth().bitmapData);
material.lights = [ _light2, _light3 ];
material.specular = 2;
material.transparent = true;
material.alphaBlending = true;
material.ambientColor = 0x202030;
material.ambient = 1;
_mesh.subMeshes[0].material = material;

material = new BitmapMaterial(new Skin().bitmapData);
material.lights = [ _light2, _light3 ];
material.gloss = 20;
material.specular = 2;
material.ambientColor = 0x202030;
material.ambient = 1;
material.specularMap = new Spec().bitmapData;
material.normalMap = new Norm().bitmapData;
_mesh.material = material;
Expand Down
18 changes: 11 additions & 7 deletions src/CelShadingTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ package
import away3d.materials.ColorMaterial;
import away3d.materials.methods.CelDiffuseMethod;
import away3d.materials.methods.CelSpecularMethod;

import away3d.materials.methods.OutlineMethod;

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
Expand All @@ -36,6 +37,7 @@ package
public function CelShadingTest()
{
_view = new View3D();
_view.backgroundColor = 0x101020;
_view.antiAlias = 4;
_light = new PointLight(); // DirectionalLight();
_light.x = 1000;
Expand Down Expand Up @@ -83,14 +85,16 @@ package
{
var mesh : Mesh;
var len : uint = _container.numChildren;
var material : ColorMaterial = new ColorMaterial(0xe24062 /*0xfbcbc1*/);
material.ambientColor = 0xaaaaaa; //0xdd5525;
var material : ColorMaterial = new ColorMaterial(0xfbcbc1);
material.ambientColor = 0xdd5525;
material.ambient = 1; //0xdd5525;
material.specular = .25;
material.diffuseMethod = new CelDiffuseMethod(2);
material.diffuseMethod = new CelDiffuseMethod(3);
material.specularMethod = new CelSpecularMethod();
CelSpecularMethod(material.specularMethod).smoothness = .2;
CelDiffuseMethod(material.diffuseMethod).smoothness = .1;
material.lights = [ _light3 ];
material.addMethod(new OutlineMethod(0x000000, 2/50));
CelSpecularMethod(material.specularMethod).smoothness = .01;
CelDiffuseMethod(material.diffuseMethod).smoothness = .01;
material.lights = [ _light, _light2, _light3 ];

for (var i : uint = 0; i < len; ++i) {
mesh = Mesh(_container.getChildAt(i));
Expand Down
2 changes: 1 addition & 1 deletion src/DOFTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package
import away3d.entities.Mesh;
import away3d.filters.DepthOfFieldFilter3D;

import away3d.filters.MotionBlurFilter3D;
import away3d.lights.DirectionalLight;
import away3d.lights.PointLight;
import away3d.materials.ColorMaterial;
Expand Down Expand Up @@ -87,6 +86,7 @@ package

_dofFilter.focusTarget = _roamer;
elementMaterial.ambientColor = 0x303040;
elementMaterial.ambient = 1;
elementMaterial.lights = [ _light, _light2 ];

_view.scene.addChild(_roamer);
Expand Down
3 changes: 2 additions & 1 deletion src/EnvMapTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ package
import away3d.loaders.parsers.OBJParser;
import away3d.materials.BitmapMaterial;
import away3d.materials.methods.EnvMapMethod;
import away3d.materials.methods.FresnelEnvMapMethod;
import away3d.materials.methods.FresnelSpecularMethod;
import away3d.materials.utils.CubeMap;
import away3d.primitives.SkyBox;

import com.bit101.components.HSlider;

import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
Expand Down
2 changes: 1 addition & 1 deletion src/FlightController.as
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ package {
_referenceX = mouseX;
_referenceY = mouseY;
_targetXRad += dx * _dragSpeed;
_targetYRad -= dy * _dragSpeed;
_targetYRad += dy * _dragSpeed;
if (_targetYRad > bound) _targetYRad = bound;
else if (_targetYRad < -bound) _targetYRad = -bound;
}
Expand Down
52 changes: 48 additions & 4 deletions src/InteractionTest.as
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package
{
import away3d.bounds.BoundingSphere;
import away3d.containers.ObjectContainer3D;
import away3d.containers.View3D;
import away3d.events.MouseEvent3D;
import away3d.materials.BitmapMaterial;
Expand All @@ -9,6 +10,8 @@ package
import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Rectangle;

Expand All @@ -22,17 +25,32 @@ package
private var _material1 : BitmapMaterial;
private var _material2 : BitmapMaterial;
private var _camController:HoverDragController;
private var _viewContainer : Sprite;
private var _dirX : Number = 1;
private var _dirY : Number = 1;
private var _container3D : ObjectContainer3D;

public function InteractionTest()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

_viewContainer = new Sprite();
_viewContainer.x = -100;
_viewContainer.y = 50;
addChild(_viewContainer);

_view = new View3D();
_view.x = 100;
_view.y = 50;
_view.width = 600;
_view.height = 300;

_container3D = new ObjectContainer3D();
_view.scene.addChild(_container3D);
_view.antiAlias = 4;
this.addChild(_view);
// _view.forceMouseMove = true;
_viewContainer.addChild(_view);

var bitmapData1 : BitmapData = new BitmapData(512, 512, false, 0x000000);
var bitmapData2 : BitmapData = new BitmapData(512, 512, false, 0x000000);
Expand All @@ -46,18 +64,37 @@ package
_mesh2.bounds = new BoundingSphere();
_mesh1.showBounds = true;
_mesh2.showBounds = true;
_view.scene.addChild(_mesh1);
_view.scene.addChild(_mesh2);

// _container3D.mouseChildren = false;
_container3D.addChild(_mesh1);
_container3D.addChild(_mesh2);

_mesh1.rotationY = .01;
_mesh2.mouseEnabled = false;
_mesh2.mouseEnabled = true;
_mesh1.mouseEnabled = true;
_mesh1.mouseDetails = true;
_mesh2.mouseDetails = true;
// _container3D.addEventListener(MouseEvent3D.CLICK, onContainerClick);
_mesh1.addEventListener(MouseEvent3D.CLICK, onClick);
_mesh2.addEventListener(MouseEvent3D.CLICK, onClick);
_mesh1.addEventListener(MouseEvent3D.MOUSE_MOVE, onMouseMove);
_mesh2.addEventListener(MouseEvent3D.MOUSE_MOVE, onMouseMove);
_camController = new HoverDragController(_view.camera, stage);

this.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
}

private function onContainerClick(event : MouseEvent3D) : void
{
_container3D.scaleX = _container3D.scaleY = _container3D.scaleZ = .8+Math.random()*.4;
}

private function onClick(event : MouseEvent3D) : void
{
var material : BitmapMaterial = event.target.material;
material.mipmap = !material.mipmap;
}

private function onMouseMove(event : MouseEvent3D) : void
{
var material : BitmapMaterial = event.target.material;
Expand All @@ -70,6 +107,13 @@ package
private function handleEnterFrame(ev : Event) : void
{
_mesh1.rotationX += .01;
_viewContainer.x += _dirX;
_viewContainer.y += _dirY;
if (_dirX > 0 && _viewContainer.x > 200) _dirX = -1;
if (_dirY > 0 && _viewContainer.y > 200) _dirY = -1;
if (_dirX < 0 && _viewContainer.x < -100) _dirX = 1;
if (_dirY > 0 && _viewContainer.y < -200) _dirY = 1;

_view.render();
}
}
Expand Down
124 changes: 124 additions & 0 deletions src/InteractionTest2.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package
{
import away3d.bounds.BoundingSphere;
import away3d.containers.ObjectContainer3D;
import away3d.containers.View3D;
import away3d.events.MouseEvent3D;
import away3d.materials.BitmapMaterial;
import away3d.primitives.Cube;
import away3d.primitives.Plane;

import flash.display.BitmapData;
import flash.display.BitmapDataChannel;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Rectangle;

[SWF(width="800", height="450", frameRate="60")]
public class InteractionTest2 extends Sprite
{
private var _view : View3D;

private var _mesh1 : Cube;
private var _mesh2 : Cube;
private var _material1 : BitmapMaterial;
private var _material2 : BitmapMaterial;
private var _camController:HoverDragController;
private var _viewContainer : Sprite;

public function InteractionTest2()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

_viewContainer = new Sprite();
_viewContainer.x = -100;
_viewContainer.y = 50;
addChild(_viewContainer);

_view = new View3D();
_view.x = 100;
_view.y = 50;
_view.width = 600;
_view.height = 300;

_view.antiAlias = 4;
_view.forceMouseMove = true;
_viewContainer.addChild(_view);

var bitmapData1 : BitmapData = new BitmapData(512, 512, false, 0x000000);
var bitmapData2 : BitmapData = new BitmapData(512, 512, false, 0x000000);
bitmapData1.perlinNoise(64, 64, 5, 0, false, true, BitmapDataChannel.RED);
bitmapData2.perlinNoise(64, 64, 5, 0, false, true, BitmapDataChannel.BLUE);
_material1 = new BitmapMaterial(bitmapData1);
_material2 = new BitmapMaterial(bitmapData1);
_material1.alpha = .9;
_mesh1 = new Cube(_material1, 10000, 1, 10000, 1, 1, 1, false);
_mesh1.bounds = new BoundingSphere();

_mesh2 = new Cube(_material2, 500, 500, 500, 1, 1, 1, false);

// _container3D.mouseChildren = false;
_view.scene.addChild(_mesh1);
_view.scene.addChild(_mesh2);

_mesh1.rotationY = .01;
_mesh1.mouseEnabled = true;
_mesh1.mouseDetails = true;
_mesh2.mouseEnabled = true;
_mesh2.mouseDetails = true;
// _container3D.addEventListener(MouseEvent3D.CLICK, onContainerClick);
_mesh1.addEventListener(MouseEvent3D.MOUSE_UP, onClick);
_mesh1.addEventListener(MouseEvent3D.MOUSE_OVER, onMouseOver);
_mesh1.addEventListener(MouseEvent3D.MOUSE_OUT, onMouseOut);
_mesh2.addEventListener(MouseEvent3D.MOUSE_MOVE, onMouseMove);
_camController = new HoverDragController(_view.camera, stage);

this.addEventListener(Event.ENTER_FRAME, handleEnterFrame);
}

private function onMouseOver(event : MouseEvent3D) : void
{
_mesh1.scaleX = _mesh1.scaleY = _mesh1.scaleZ = 1.1;
}

private function onMouseOut(event : MouseEvent3D) : void
{
_mesh1.scaleX = _mesh1.scaleY = _mesh1.scaleZ = 1;
}

private function onClick(event : MouseEvent3D) : void
{
var material : BitmapMaterial = event.target.material;
material.mipmap = !material.mipmap;

var rect : Rectangle = new Rectangle(event.uv.x*material.bitmapData.width-4, event.uv.y*material.bitmapData.height-4, 9, 9);
material.bitmapData.fillRect(rect, 0x00ff00);
material.updateTexture();
}

private function onMouseMove(event : MouseEvent3D) : void
{
var material : BitmapMaterial = event.target.material;
var rect : Rectangle = new Rectangle(event.uv.x*material.bitmapData.width-4, event.uv.y*material.bitmapData.height-4, 9, 9);
material.bitmapData.fillRect(rect, 0x00ff00);
material.updateTexture();
}


private function handleEnterFrame(ev : Event) : void
{
_mesh1.rotationX += 1;
// _viewContainer.x += _dirX;
// _viewContainer.y += _dirY;
// if (_dirX > 0 && _viewContainer.x > 200) _dirX = -1;
// if (_dirY > 0 && _viewContainer.y > 200) _dirY = -1;
// if (_dirX < 0 && _viewContainer.x < -100) _dirX = 1;
// if (_dirY > 0 && _viewContainer.y < -200) _dirY = 1;

_view.render();
}
}
}
Loading