0

我是 JS 新手,最近我发现了一个 SDK,用于使用 html/css/js 创建增强现实应用程序,称为 wikiitude。当您在下面看到时,您会看到一个按钮,单击该按钮会调用 scaleModel 函数,该函数随后会为 scale 属性创建新值,这将允许我的应用程序显示的 3d 模型的大小增加。我只想能够创建一个按钮,每次按下它都会增加值,而另一个按钮会在每次按下它时减小值。这样我将有两个按钮,一个用于增加尺寸,另一个用于减小尺寸。我非常感谢您的帮助。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="target-densitydpi=device-dpi, width = 540, user-scalable = 0" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My ARchitect World</title>
<script src="architect://architect.js"></script>
<script>
var model;
var location;

function createModel()
{
AR.logger.activateDebugMode();
AR.logger.info("info");

var modelOptions = {
    scale: {x: 0.1, y: 0.1, z: 0.1},
    rotate: {heading: -30},
    rotate: {tilt: 30},
    translate: {y: -0.5}
};

model = new AR.Model("my3dModel.wt3", modelOptions);
location = new AR.RelativeLocation(null, 0, -50, 0);
var myGeoObject = new AR.GeoObject(location, {drawables: {cam: model}});
}

function scaleModel() {
model.scale.x = 0.5;
model.scale.y = 0.5;
model.scale.z = 0.5;
}

</script>
</head>

创建动画比例

4

1 回答 1

1

If you make a new function like the scaleModel() function that multiplies the scale by an amount instead of setting it:

function scaleModelBy(amount) {
    model.scale.x = model.scale.x * amount;
    model.scale.y = model.scale.y * amount;
    model.scale.z = model.scale.z * amount;
}

You can then call it in some buttons:

<button onclick="scaleModelBy(2);">Scale up</button>
<button onclick="scaleModelBy(0.5);">Scale down</button>
于 2013-04-17T04:36:56.227 回答