如何创建具有 2 个相同纹理边的 3D 点?
因此,我不使用 3D 引擎而是使用 Flash 中的引擎创建点云:
import flash.display.Bitmap;
import flash.display.BitmapData;
var bmd:BitmapData = new BitmapData(400,400,true,0x00000000);
var xn:Number;
var yn:Number;
var zn:Number;
var norm:Number;
var c1:Number;
var c2:Number;
var c3:Number;
var c4:Number;
var counter:int;
var color:uint;
while (counter < 20000)
{
xn = Math.random() * 400;
yn = Math.random() * 400;
zn = Math.random() * 400;
norm = Math.sqrt(xn * xn + yn * yn + zn * zn);
c1 = (1 - norm / 200) * 255;
c2 = (1 - norm / 250) * 255;
c3 = Math.abs(xn) / norm * 255;
c4 = Math.abs(yn) / norm * 255;
color = (c1 << 24 | c2 << 16 | c3 << 8 | c4);
counter++;
var pointGraphicData = new BitmapData(1,1,true,color);
var pointGraphic:Bitmap = new Bitmap(pointGraphicData);
pointGraphic.x = xn;
pointGraphic.y = yn;
pointGraphic.z = zn;
addChild(pointGraphic);
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove );
this.x = 150;
this.y = 150;
this.z = 450;
function handleMouseMove( event:MouseEvent ):void
{
this.rotationX = 0 - event.localX;
this.rotationY = 0 - event.localY;
this.rotationZ = 0 - Math.sqrt((event.localX * event.localX + event.localY * event.localY ));
}
因此这是一个谨慎的简单代码。如何使我的观点有两个侧面或始终面向wiever?
So I create a points cloud using no 3d engines but one baked into flash:
import flash.display.Bitmap;
import flash.display.BitmapData;
var bmd:BitmapData = new BitmapData(400,400,true,0x00000000);
var xn:Number;
var yn:Number;
var zn:Number;
var norm:Number;
var c1:Number;
var c2:Number;
var c3:Number;
var c4:Number;
var counter:int;
var color:uint;
while (counter < 20000)
{
xn = Math.random() * 400;
yn = Math.random() * 400;
zn = Math.random() * 400;
norm = Math.sqrt(xn * xn + yn * yn + zn * zn);
c1 = (1 - norm / 200) * 255;
c2 = (1 - norm / 250) * 255;
c3 = Math.abs(xn) / norm * 255;
c4 = Math.abs(yn) / norm * 255;
color = (c1 << 24 | c2 << 16 | c3 << 8 | c4);
counter++;
var pointGraphicData = new BitmapData(1,1,true,color);
var pointGraphic:Bitmap = new Bitmap(pointGraphicData);
pointGraphic.x = xn;
pointGraphic.y = yn;
pointGraphic.z = zn;
addChild(pointGraphic);
}
stage.addEventListener(MouseEvent.MOUSE_MOVE, handleMouseMove );
this.x = 150;
this.y = 150;
this.z = 450;
function handleMouseMove( event:MouseEvent ):void
{
this.rotationX = 0 - event.localX;
this.rotationY = 0 - event.localY;
this.rotationZ = 0 - Math.sqrt((event.localX * event.localX + event.localY * event.localY ));
}
so its a wary simple code. how to make my points have 2 sides or be always face to wiever?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此链接有一个关于如何在球体表面上创建螺旋的 JavaScript 示例:
http://lines-about-to-be- generated.blogspot.com/2009/06/image-spiral-sphere.html
There's a javascript example of how to create a spiral on a sphere surface at this link:
http://lines-about-to-be-generated.blogspot.com/2009/06/image-spiral-sphere.html