package laya.d3.core {
import laya.d3.graphics.IndexBuffer3D;
import laya.d3.graphics.VertexBuffer3D;
import laya.d3.graphics.VertexDeclaration;
import laya.d3.graphics.VertexElement;
import laya.d3.graphics.VertexElementFormat;
import laya.d3.graphics.VertexElementUsage;
import laya.d3.math.Vector3;
import laya.d3.math.Vector4;
import laya.d3.shader.Shader3D;
import laya.d3.shader.ShaderCompile3D;
import laya.d3.shader.ValusArray;
import laya.utils.Stat;
import laya.webgl.WebGL;
import laya.webgl.WebGLContext;
/**
* @private
* <code>PhasorSpriter3D</code> 类用于创建矢量笔刷。
*/
public class PhasorSpriter3D {
/**混合状态_不透明*/
public static const BLENDSTATE_OPAQUE:int = 0;
/**混合状态_加色法*/
public static const BLENDSTATE_ADDITIVE:int = 1;
/**混合状态_透明混合*/
public static const BLENDSTATE_ALPHABLEND:int = 2;
/**深度状态_默认*/
public static const DEPTHSTATE_DEFAULT:int = 0;
/**深度状态_只读*/
public static const DEPTHSTATE_ONLYREAD:int = 1;
/**深度状态_无*/
public static const DEPTHSTATE_NONE:int = 2;
private static const _vertexDeclaration:VertexDeclaration = new VertexDeclaration(28, [new VertexElement(0, VertexElementFormat.Vector3, VertexElementUsage.POSITION0), new VertexElement(12, VertexElementFormat.Vector4, VertexElementUsage.COLOR0)]);
private var _tempInt0:int;
private var _tempInt1:int;
private var _tempUint0:uint;
private var _tempUint1:uint;
private var _tempUint2:uint;
private var _tempUint3:uint;
private var _tempUint4:uint;
private var _tempUint5:uint;
private var _tempUint6:uint;
private var _tempUint7:uint;
private var _tempNumver0:Number;
private var _tempNumver1:Number;
private var _tempNumver2:Number;
private var _tempNumver3:Number;
private const _floatSizePerVer:int = 7;//顶点结构为Position(3个float)+Color(4个float)
private const _defaultBufferSize:int = 600 * _floatSizePerVer;
private var _vbData:Float32Array = new Float32Array(_defaultBufferSize);
private var _vb:VertexBuffer3D;
private var _posInVBData:uint;
private var _ibData:Uint16Array = new Uint16Array(_defaultBufferSize);
private var _ib:IndexBuffer3D;
private var _posInIBData:uint;
private var _primitiveType:Number;
private var _blendState:Number;
private var _depthState:Number;
private var _hasBegun:Boolean;
private var _numVertsPerPrimitive:uint;
private var _camera:BaseCamera;
private var _sharderNameID:int;
private var _shader:Shader3D;
/** @private */
protected var _shaderCompile:ShaderCompile3D;
/** @private */
private var _spriteShaderValue:ValusArray = new ValusArray();
public function PhasorSpriter3D() {
super();
_vb = VertexBuffer3D.create(_vertexDeclaration, _defaultBufferSize / _floatSizePerVer, WebGLContext.DYNAMIC_DRAW);
_ib = IndexBuffer3D.create(IndexBuffer3D.INDEXTYPE_USHORT, _defaultBufferSize, WebGLContext.DYNAMIC_DRAW);
_sharderNameID = Shader3D.nameKey.getID("LINE");
_shaderCompile = ShaderCompile3D._preCompileShader[_sharderNameID];
}
public function line(startPosition:Vector3, startColor:Vector4, endPosition:Vector3, endColor:Vector4):PhasorSpriter3D {
if (!_hasBegun || _primitiveType !== WebGLContext.LINES)
drawLinesException();
if (_posInVBData + 2 * _floatSizePerVer > _vbData.length || _posInIBData + 2 > _ibData.length)
_flush();
_tempUint0 = _posInVBData / _floatSizePerVer;//_tempUint0为curVBPosVertex
addVertex(startPosition.x, startPosition.y, startPosition.z, startColor.x, startColor.y, startColor.z, startColor.w); // start
addVertex(endPosition.x, endPosition.y, endPosition.z, endColor.x, endColor.y, endColor.z, endColor.w); // end
addIndexes(_tempUint0, _tempUint0 + 1);
return this;
}
public function circle(radius:Number, numberOfPoints:uint, r:Number, g:Number, b:Number, a:Number):PhasorSpriter3D {
if (!_hasBegun || (_primitiveType !== WebGLContext.LINES))
drawLinesException();
_tempUint0 = numberOfPoints * 2;//_tempUint0为总顶点数
if (_posInVBData + _tempUint0 * _floatSizePerVer > _vbData.length || _posInIBData + 2 * _tempUint0 > _ibData.length)
_flush();
_tempUint1 = _posInVBData / _floatSizePerVer;//_tempUint1为curVBPosVertex
for (_tempNumver0 = 0, _tempInt0 = 0; _tempNumver0 < 3.1416 * 2; _tempNumver0 = _tempNumver0 + (3.1416 / numberOfPoints), _tempInt0++) {
addVertex(Math.sin(_tempNumver0) * radius, Math.cos(_tempNumver0) * radius, 0, r, g, b, a);
if (_tempInt0 === 0) {
addIndexes(_tempUint1);
} else if (_tempInt0 === _tempUint0 - 1) {
_tempUint2 = _tempUint1 + _tempInt0;//_tempUit2为当前索引数
addIndexes(_tempUint2, _tempUint2, _tempUint1);
} else {
_tempUint2 = _tempUint1 + _tempInt0; //_tempUint2为当前索引数
addIndexes(_tempUint2, _tempUint2);
}
}
return this;
}
public function plane(positionX:Number, positionY:Number, positionZ:Number, width:Number, height:Number, r:Number, g:Number, b:Number, a:Number):PhasorSpriter3D {
if (!_hasBegun || _primitiveType !== WebGLContext.TRIANGLES)
drawTrianglesException();
if (_posInVBData + 4 * _floatSizePerVer > _vbData.length || _posInIBData + 6 > _ibData.length)
_flush();
_tempNumver0 = width / 2;//tempNumver0为halfWidth
_tempNumver1 = height / 2;//tempNumver1为halfHeight
_tempUint0 = _posInVBData / _floatSizePerVer;//_tempUint0为curVBPosVertex
addVertex(positionX - _tempNumver0, positionY + _tempNumver1, positionZ, r, g, b, a); // LeftUp
addVertex(positionX + _tempNumver0, positionY + _tempNumver1, positionZ, r, g, b, a); // RightUp
addVertex(positionX - _tempNumver0, positionY - _tempNumver1, positionZ, r, g, b, a); // LeftBottom
addVertex(positionX + _tempNumver0, positionY - _tempNumver1, positionZ, r, g, b, a); // RightBottom
_tempUint1 = _tempUint0 + 1;//_tempUint0为curVBPosVertex1
_tempUint2 = _tempUint0 + 2;//_tempUint1为curVBPosVertex2
addIndexes(_tempUint0, _tempUint1, _tempUint2, _tempUint2, _tempUint1, _tempUint0 + 3);
return this;
}
public function box(positionX:Number, positionY:Number, positionZ:Number, width:Number, height:Number, depth:Number, r:Number, g:Number, b:Number, a:Number):PhasorSpriter3D {
if (!_hasBegun || _primitiveType !== WebGLContext.TRIANGLES)
drawTrianglesException();
if (_posInVBData + 8 * _floatSizePerVer > _vbData.length || _posInIBData + 36 > _ibData.length)
_flush();
_tempNumver0 = width / 2;//tempNumver0为halfWidth
_tempNumver1 = height / 2;//tempNumver1为halfHeight
_tempNumver2 = depth / 2;//tempNumver2为halfDepth
_tempUint0 = _posInVBData / _floatSizePerVer;//_tempUint0为curVBPosVertex
//frontVertex
addVertex(positionX - _tempNumver0, positionY + _tempNumver1, positionZ + _tempNumver2, r, g, b, a); // V0
addVertex(positionX + _tempNumver0, positionY + _tempNumver1, positionZ + _tempNumver2, r, g, b, a); // V1
addVertex(positionX - _tempNumver0, positionY - _tempNumver1, positionZ + _tempNumver2, r, g, b, a); // V2
addVertex(positionX + _tempNumver0, positionY - _tempNumver1, positionZ + _tempNumver2, r, g, b, a); // V3
//backVertex
addVertex(positionX + _tempNumver0, positionY + _tempNumver1, positionZ - _tempNumver2, r, g, b, a); // V4
addVertex(positionX - _tempNumver0, positionY + _tempNumver1, positionZ - _tempNumver2, r, g, b, a); // V5
addVertex(positionX + _tempNumver0, positionY - _tempNumver1, positionZ - _tempNumver2, r, g, b, a); // V6
addVertex(positionX - _tempNumver0, positionY - _tempNumver1, positionZ - _tempNumver2, r, g, b, a); // V7
// v5----- v4
// /| /|
// v0----- v1
没有合适的资源?快使用搜索试试~ 我知道了~
LayaAir1.0版 俄罗斯方块
共931个文件
as:751个
ps:40个
vs:38个
需积分: 10 7 下载量 34 浏览量
2019-04-11
22:11:05
上传
评论 1
收藏 2.41MB RAR 举报
温馨提示
还有好多不完善的地方,但基本可以玩。操控数据层与显示层,下一个方块显示的是当前的方块,希望有大神完善一下。
资源推荐
资源详情
资源评论
收起资源包目录
LayaAir1.0版 俄罗斯方块 (931个子文件)
.actionScriptProperties 4KB
ShurikenParticleSystem.as 84KB
DivScripts.as 77KB
Sprite.as 61KB
WebGLContext2D.as 55KB
ShaderInit3D.as 53KB
TiledMap.as 45KB
Animator.as 39KB
Scene.as 39KB
Collision.as 38KB
ShuriKenParticle3D.as 37KB
Text.as 36KB
Utils3D.as 32KB
Skeleton.as 32KB
Laya3D.as 31KB
List.as 31KB
Graphics.as 30KB
Sprite3D.as 28KB
ParallelSplitShadowMap.as 28KB
Stage.as 28KB
WebGLContext.as 27KB
OrientedBoundBox.as 26KB
Templet.as 26KB
WebGL.as 25KB
Base64AtlasManager.as 25KB
Ease.as 24KB
Matrix4x4.as 24KB
Shader3D.as 23KB
Byte.as 22KB
DebugTool.as 22KB
BaseMaterial.as 22KB
Tree.as 21KB
CSSStyle.as 21KB
Button.as 21KB
TerrainLeaf.as 21KB
Quaternion.as 20KB
Animation.as 20KB
LoaderManager.as 20KB
Input.as 20KB
StandardMaterial.as 20KB
Earcut.as 19KB
Transform3D.as 19KB
Shader.as 19KB
Node.as 19KB
RenderContext.as 18KB
Loader.as 18KB
Context.as 18KB
ShurikenParticleData.as 18KB
ComboBox.as 18KB
PathConstraint.as 17KB
ScrollBar.as 17KB
Matrix.as 17KB
BaseCamera.as 16KB
MiniFileMgr.as 16KB
GlitterTemplet.as 16KB
Vector3.as 16KB
MapLayer.as 16KB
BaseRender.as 16KB
VRCamera.as 15KB
AnimationPlayer.as 15KB
PhasorSpriter3D.as 15KB
LoadModelV03.as 15KB
AnimationNode.as 15KB
Component.as 15KB
OctreeNode.as 15KB
RenderSprite.as 15KB
Video.as 15KB
AnimationTemplet.as 14KB
LayaSample.as 14KB
RenderQueue.as 14KB
ColorPicker.as 14KB
Clip.as 14KB
ShaderCompile.as 14KB
SkinAnimations.as 14KB
LoadModelV02.as 14KB
TimeLine.as 14KB
StringTool.as 14KB
TrailRenderElement.as 14KB
GraphicAnimation.as 14KB
Dialog.as 13KB
LoadModelV01.as 13KB
Label.as 13KB
Layout.as 13KB
Texture.as 13KB
GradientAngularVelocity.as 13KB
MovieClip.as 13KB
BoneSlot.as 13KB
Utils.as 13KB
wx.as 12KB
GlUtils.as 12KB
UIGroup.as 12KB
BlinnPhongMaterial.as 12KB
SoundManager.as 12KB
PBRStandardMaterial.as 12KB
MouseManager.as 12KB
PBRSpecularMaterial.as 12KB
BasePoly.as 12KB
BoundFrustum.as 12KB
AnimationClip.as 12KB
TerrainFilter.as 12KB
共 931 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
知识的追随者
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功