我正在 Win-7 32 位上以解释模式(即不是作为 .exe)运行旧的 VB6.0 程序。
该程序通过函数中的 MSScriptControl.ScriptControl(如下面的代码块所示)访问 VBScript,calc该函数在这里由测试函数调用,tc该函数本身可以从另一个子函数或函数调用,或者通过键入从直接窗格调用tc <expression>。这<expression>是一个数字数学表达式,例如2+3^2*(9-3.5)^3.
当输入表达式包含像这样的模式时,-a^b结果有时会让我感到惊讶。(这里a,b是实数的占位符 - 我不希望calc处理包含变量名的表达式。)
根据基于 VB6 行为的运算符优先级规则,我期望-a^b --> -(a^b) 但经常-a^b --> +(a^b)。正如预期的那样,表达式内的空格没有明显的效果。
在下面显示的不同结果中Cases,我用“ok”标记一致的结果,用“?”标记不一致的结果。
a^b我可以通过将每个 case 括起来来解决这个问题(a^b)。但是,考虑到我正在处理很长的复杂方程,这将 (i) 实现起来很乏味,并且 (ii) 会损害代码的可读性。
这种行为是否为人所知?是否有“幕后”修复(例如软件补丁或版本升级)?
vb6
Public Function calc(ipEqtn$)
Set objScript = CreateObject("MSScriptControl.ScriptControl")
objScript.Language = "VBScript"
calc = objScript.eval(ipEqtn$)
End Function '... calc
Public Function tc(n)
Select Case (n)
Case …Run Code Online (Sandbox Code Playgroud) 我的 object3D 有一个向上向量 (0,1,0)。object3D 围绕偏航、俯仰和滚动移动其原点。
我的问题:如何找到在世界坐标中显示 object3D 向上向量方向的向量?
编码上下文示例:-
var v1 = new THREE.Vector3();
v1.add( givenObject3D.up ); // now v1 = (0,1,0)
givenObject3D.updateMatrixWorld();
FunctionXXX (v1, givenObject3D.matrixWorld );
//... now v1 is a vector in world coordinates
//... v1 points in the same direction as the givenObject3D's up vector.
v1.normalize();
Run Code Online (Sandbox Code Playgroud) 我可以使用 THREE.js“lookAt”函数让我的锥体依次指向每个目标球体(红色、绿色、黄色、蓝色)。
// Initialisation
c_geometry = new THREE.CylinderGeometry(3, 40, 120, 40, 10, false);
c_geometry.applyMatrix( new THREE.Matrix4().makeRotationX( Math.PI / 2 ) );
c_material = new THREE.MeshNormalMaterial()
myCone = new THREE.Mesh(c_geometry, c_material);
scene.add(myCone);
// Application (within the Animation loop)
myCone.lookAt(target.position);
Run Code Online (Sandbox Code Playgroud)
但现在我希望锥体能够平稳、缓慢地从旧目标平移到新目标。我想我可以通过计算以圆锥中心 Cxyz 为中心并从先前目标位置 Pxyz 到新目标位置 Nxyz 的圆弧上的中间点来实现。
请有人给我指出合适的:(a) 实用程序或 (b) 三角算法或 (c) 用于计算此类弧上中间点的 xyz 坐标的代码示例?(我将根据所需的扫描速率和帧之间的时间间隔提供点之间的角度增量)。
我一直在玩 GPUComputationRenderer 在这个 Three.js 示例的修改版本上,该示例使用 GPU 着色器来修改交互 boid 的速度,以保存、读取和操作 boid 位置和速度数据。
我已经到了可以使用着色器将 GPU 计算数据(预测碰撞时间)放入纹理缓冲区的阶段。但是现在我想在主要的 javascript 动画脚本中读取一些纹理数据(以找到最早的碰撞)。
这是渲染函数中的相关代码(在每个动画传递中调用)
//... GPU calculations as per original THREE.js example
gpuCompute.compute(); //... gpuCompute is the gpu computation renderer.
birdUniforms.texturePosition.value = gpuCompute.getCurrentRenderTarget( positionVariable ).texture;
birdUniforms.textureVelocity.value = gpuCompute.getCurrentRenderTarget( velocityVariable ).texture;
var xTexture = birdUniforms.texturePosition.value;//... my variable, OK.
//... From http://zhangwenli.com/blog/2015/06/20/read-from-shader-texture-with-threejs/
//... but note that this reads from the main THREE.js renderer NOT from the gpuCompute renderer.
//var pixelBuffer = new Uint8Array(canvas.width * canvas.height …Run Code Online (Sandbox Code Playgroud) Trackball works well in my three.js program along with onMouseClick and onMouseUp event listeners. I enable Trackball using the line:-
controls = new THREE.TrackballControls( scene01camera02 , DOM_container);
Run Code Online (Sandbox Code Playgroud)
But the onMouseDown event listener does not work.
If I disable trackball (by commenting out the line of code shown above) and disable any other related code then onMouseDown works fine.
Is there some way to use both onMouseDown and Trackball control at the same time?
The reason is so that when a …