小编App*_*cow的帖子

我怎样才能在three.js中使用反射?

我希望在带有Three.js的WebGL页面中有一个反射立方体表面.它应该像手机显示器,它反射一些光,但它仍然必须是黑色的.

javascript webgl three.js

7
推荐指数
1
解决办法
1万
查看次数

如何在WebGL中使用多个纹理?

我想在立方体上使用6种不同的纹理,每边一个,但是找不到错误.这是我目前的代码:

   var texturen = new Array();
function initTexture(sFilename,texturen)  
{
  var anz = texturen.length;
  texturen[anz] = gl.createTexture();
  texturen[anz].image = new Image();
  texturen[anz].image.onload = function()    
  {
  gl.bindTexture(gl.TEXTURE_2D, texturen[anz]);
  gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
  gl.texImage2D
  (gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texturen[anz].image);
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  gl.bindTexture(gl.TEXTURE_2D, null);
  }
  texturen[anz].image.src = sFilename;
} 


var mvMatrix = mat4.create();
var mvMatrixStack = [];
var pMatrix = mat4.create();

function mvPushMatrix() {
    var copy = mat4.create();
    mat4.set(mvMatrix, copy);
    mvMatrixStack.push(copy);
}

function mvPopMatrix() {
    if (mvMatrixStack.length == 0) {
        throw …
Run Code Online (Sandbox Code Playgroud)

javascript textures opengl-es webgl

6
推荐指数
1
解决办法
7711
查看次数

vue.js 注册Web组件

我正在使用 vue.js 并使用 stencil.js 创建了一个 web 组件。我不想将 Web 组件发布到 npm,这就是为什么我只是将其包含在我的 vue 项目的 src/assets 目录中。

但是我收到错误

[Vue warn]: Unknown custom element: <my-component> - did you register the component correctly? For recursive components, make sure to provide the "name" option. 
    found in ---> 
        <App> at src/app.vue
            <Root>
Run Code Online (Sandbox Code Playgroud)

它与我在资产目录中已有的另一个组件一起工作没有问题。

它也无助于使用

Vue.config.ignoredElements = ['my-component'];
Run Code Online (Sandbox Code Playgroud)

因为当我在本地运行该组件时,该组件仍然是空的。

感谢您的帮助!

web-component vue.js vuejs2 stenciljs

5
推荐指数
1
解决办法
752
查看次数

在three.js中编写一个空洞/空白区域

我想编写类似于three.js中的漏洞的东西.它应该是,例如一个3x3x3立方体,其中有1x1x1个洞.是否有可能,我首先使用像cubegeometry这样的东西,然后再使用另一个"几何"来削减我想要删除的东西?删除几何?:d

谢谢 :)

javascript three.js

4
推荐指数
1
解决办法
2088
查看次数

使用webGL绘制元素

我有面部索引(指向点)和点,并希望在循环中绘制三角形.Web控制台给我这个错误:

WebGL: drawElements: bound element array buffer is too small for given count and offset
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

for(var i=1;i<38000;i++){
 var vtx = new Float32Array(
 [points[faces[i][1]][1],points[faces[i][1]][2],points[faces[i][1]][3],
  points[faces[i][2]][1],points[faces[i][2]][2],points[faces[i][2]][3],
  points[faces[i][3]][1],points[faces[i][3]][2],points[faces[i][3]][3]
]
);
var idx = new Uint16Array([0, 1]);
initBuffers(vtx, idx);
gl.lineWidth(1.0);
gl.uniform4f(shaderProgram.colorUniform, 0, 0, 0, 1);
gl.drawElements(gl.LINES, 3, gl.UNSIGNED_SHORT, 0);
unbindBuffers();
}
}
Run Code Online (Sandbox Code Playgroud)

例程没有任何东西.我该如何解决这个问题?

javascript webgl

3
推荐指数
1
解决办法
4756
查看次数

将图像调整为父div

我有一个600px宽度的图像。

它必须位于宽度为的引导程序col-xs-612div 内,300px并且如果屏幕宽度小于,则必须调整其大小300px

如何在CSS 中使用widthmax-width

css image twitter-bootstrap

2
推荐指数
2
解决办法
2845
查看次数

使用变量作为 jquery css 属性名称

我见过很多线程询问如何为 jquery 的 css 方法使用变量,例如

var black='#000000';
$(this).css({'color':black});
Run Code Online (Sandbox Code Playgroud)

但没有人像这样反过来使用变量

var bg='background-color';
$(this).css({bg:'#000000'});
Run Code Online (Sandbox Code Playgroud)

对我来说,它不是这样工作的,所以我问,有没有办法让类似的东西工作,以便在脚本中多次使用“背景颜色”时节省一些空间?

谢谢!

javascript css jquery

2
推荐指数
1
解决办法
1174
查看次数

bootstrap datepicker 默认查看日期

我想使用具有特定默认日期的日期选择器,但不知何故这不起作用:

<input class="cal-datepicker" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-autoclose="true" data-date-today-highlight="true" data-date-default-view-date="01/01/2015">
Run Code Online (Sandbox Code Playgroud)

我怎样才能让它工作?

jquery datepicker twitter-bootstrap

0
推荐指数
1
解决办法
5733
查看次数

如何在WebGL中的多维数据集上使用多个纹理?

这是我的源代码.它仍然无法正常工作.我想在一个立方体的6面上放置6张不同的图片,这是动画的.请帮忙 :)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>WebGL</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">


<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script>

<script type="text/javascript" src="webgl-utils.js"></script>

<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;

varying vec2 vTextureCoord;

uniform sampler2D uSampler;

void main(void) {
    gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
}
</script>

<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec2 aTextureCoord;

uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;

varying vec2 vTextureCoord;


void main(void) {
    gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
    vTextureCoord = aTextureCoord;
}
</script>


<script type="text/javascript">

var …
Run Code Online (Sandbox Code Playgroud)

javascript textures opengl-es webgl

-1
推荐指数
1
解决办法
3345
查看次数