Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize onframe Walking along the Line by js

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to realize the onframe walking along the js". In the daily operation, I believe many people have doubts about how to realize the onframe walking along the js. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to realize the onframe walking along the js". Next, please follow the editor to study!

The following is a list of a practical application, how to move a model file dynamically online along a well-made line.

Here is the specific js code:

/ / A general function, how to convert the point type of geometry in te into position position

Function pointToPostion (point,altitudeType)

{

Var postionl=SGWorld.Creator.CreatePosition (point.X,point.Y,point.Z,altitudeType,0,0,0,0)

Return postionl

}

/ / define walking model, time and other parameters

Var model = null

Var time

Var linePointCount=0

Var i

Var altitudeType

Var linePoint

Function Init ()

{

ITunes 0

/ / find the pre-drawn line object

Var item = SGWorld.ProjectTree.FindItem ("Line\\ path")

Var poly = SGWorld.ProjectTree.GetObject (item)

/ / get the geometry and height type of the line object, and the points contained in the line

Var polygonGeometry = poly.Geometry

AltitudeType=poly.Position.AltitudeType

LinePoint= polygonGeometry.Points

LinePointCount=polygonGeometry.Points.Count

Var fpos=pointToPostion (linePoint.Item (I), altitudeType)

/ / initialization time and onframe event

Time = new Date ()

SGWorld.AttachEvent ("onFrame", onFrame); / / create a new walking model

Model = SGWorld.Creator.CreateModel (fpos, "D:\\ skylinedata\\ villain .xpl", 3)

}

/ / onframe time implementation, which is the key to the code

Function onFrame ()

{

/ / Walk according to the points in the line, from the first point to the last one. When the point is greater than the number of points, the path is finished.

If (I)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report