小编Abu*_*sae的帖子

Three.js调整画布大小

我一直致力于3D项目,我们使用Three.js Library在Web浏览器中显示3D对象.

问题是:

  • 首先,模型显示在一个小的dom元素中,或者当浏览器窗口本身很小时.
  • 然后,当窗口(或dom元素调整大小)时,模型变为像素化

以下是一些截图:

在调整大小之前:

在此输入图像描述

调整大小后:

在此输入图像描述

调整大小后应该如何:

在此输入图像描述

下面是设置模型尺寸(高度和宽度)的代码部分,如果触发了resize事件,则会调用此函数:

console.log("domChanged fired")

instance.domBoundingBox = instance.dom.getBoundingClientRect();
instance.domCenterPos.x = instance.domBoundingBox.width / 2 + instance.domBoundingBox.left;
instance.domCenterPos.y = instance.domBoundingBox.height / 2 + instance.domBoundingBox.top;

var width = instance.dom.clientWidth, height = instance.dom.clientHeight;
instance.domWidthHalf = width / 2, instance.domHeightHalf = height / 2;

// TODO: fire event to expose it to site developers

// here we should update several values regarding width,height,position
if(instance.cameraReal) {
    instance.cameraReal.aspect = instance.dom.clientWidth / instance.dom.clientHeight;
    instance.cameraReal.updateProjectionMatrix();
}

if(instance.renderer3D)
    instance.renderer3D.setSize(instance.dom.clientWidth, instance.dom.clientHeight);
Run Code Online (Sandbox Code Playgroud)

任何人都可以给我一个提示吗?我已经做了几天,但到目前为止还没有任何线索

javascript three.js

34
推荐指数
3
解决办法
4万
查看次数

Does negative z-index have any side effects

I've been searching for a while for an answer to my question:

Does negative z-index have any side effects

And I've already asked before here: Does negative z-index affect performance or compatibility? but it doesn't get enough attention (may be because I mixed things a little bit)

And I wanted to try and asked in a other way.

我正在为跨平台(不同的浏览器,设备)开发一个Web应用程序,有时我需要为z-index属性使用负值,但我担心它是否会对任何/某些产生任何副作用浏览器并打破兼容性.

我希望我明白这个问题:)

html5 cross-platform cross-browser css3

11
推荐指数
1
解决办法
2547
查看次数

从NodeJS中的base64字符串创建图像

我正在尝试上传从我的画布中提取并通过ajax发布的图像,而我在服务器端创建图像文件时遇到问题.

我有以下答案:https://stackoverflow.com/a/7347358/1358670,但我似乎仍然想念这里或那里的东西.

这是我的javascript(浏览器)代码:

var img = myCanvas.toDataURL("image/jpeg");

// ajax request to send the image
Run Code Online (Sandbox Code Playgroud)

在服务器端,我执行以下操作:

var fd =  fs.openSync('./img.jpeg', 'w');
req.body.image = req.body.image.replace(/^data:image\/\w+;base64,/, "");
console.log( req.body.image );

var buff = new Buffer(req.body.image, 'base64');
fs.write(fd, buff, 0, buff.length, 0, function(err,written){
    console.log( ">> "+ err );
    fs.closeSync( fd );
});
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我已经记录了图像以查看它是否已正确发送,而且仍然是我无法打开创建的img.jpeg文件

我们非常欢迎任何帮助或提示.


编辑

我也尝试过这里的解决方案:https://stackoverflow.com/a/6933413/1358670但我仍然有同样的问题


编辑:2

我已经测试了我的前端,在服务器端使用PHP脚本,并且生成的图像非常好,所以我得出结论,问题出在我的NodeJS代码中.

base64 image ajax-upload node.js

8
推荐指数
1
解决办法
4935
查看次数

使用PHP将RTL(阿拉伯语)文本写入图像

我想生成一个带有一些文字的图像,LTR语言似乎工作得很好,但是在阿拉伯语中尝试它时,它简单地说不起作用,请看下面的截图,我在其中绘制3个文本字符串提出了文本代码

在此输入图像描述

这是我的测试代码(带一些注释):

// Create a 300*300 image
$im = imagecreate(300, 300);

// Yellow transparent background and blue text
$bg = imagecolorallocatealpha($im, 255, 255, 0, 45);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// Write an LTR string
imagestring($im, 5, 250, 100, 'test', $textcolor);

$font = 'DroidKufi-Regular.ttf'; // specify the fonts file
$text = "?????";
// Add the text
imagettftext($im, 10, 0, 10, 20, $textcolor, $font, $text);


// set a red text color 
$textcolor = imagecolorallocate($im, 255, 0, 0);

// strrev doesn't …
Run Code Online (Sandbox Code Playgroud)

php image image-processing

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

如何在htaccess中引用当前目录

我需要动态获取 .htaccess 文件所在的当前目录。那可能吗 ?(也许是一个变量?)。

就像是 :%{SCRIPT_FILENAME}

先感谢您。

编辑:如果使用正则表达式?它应该是什么样子?

regex .htaccess apache2 global-variables

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

完全卸载CouchDB Mac OSX

我已经玩了我的couchdb配置,我想重新开始,删除应用程序并下载一个新的似乎没有完全删除配置,我仍然需要访问我的用户名和密码,我的dbs仍在那里.

在互联网上四处看看,我似乎没有找到解决方案来解决mac os x(mavericks)上的问题

好吧,我做过一些事情,比如:

  • 从中删除缓存文件夹 ~/Library/Caches
  • 删除任何相关的文件/文件夹~/Library/Application Support/CouchDB
  • 检查配置文件~/Library/Preferences/couchdb-server.ini似乎是Application SupportCouchDB文件夹中配置文件的别名
  • 我也删除了几个文件,我不记得他们的名字

仍然安装一个新的下载couchdb不工作的应用程序,现在我收到json消息: {"错误":"未授权","原因":"名称或密码不正确."}

PS:我的系统是Mac OS X MavericksCouchdb 1.5.1

couchdb addremoveprograms osx-mavericks

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

带有Switch语句的$ _GET

我有很多获取值来定义用户将要看到的页面,例如"profile"我将显示配置文件页面等等.

找出要显示的页面我尝试做类似的事情:

switch ($_GET) {
    case 'profile':
        require_once('function/profile.php');
        break;
    case 'team':
        require_once('function/team.php');
        break;
Run Code Online (Sandbox Code Playgroud)

但它没有显示结果..

我发送GET请求:index.php?profile,例如..

这里有什么问题,我怎么能设法做类似的工作呢.先感谢您!

php

5
推荐指数
3
解决办法
7253
查看次数

没有http的链接:如//code.jquery.com/etc

最近我注意到一些网站(比如jsFiddle)和一些小部件这样的pinterest feed widget等等.

他们开始使用格式的链接

  • //code.jquery.com/jquery-1.9.1.js
  • //assets.pinterest.com/js/pinit.js

    1. 什么是//手段?
    2. 它是一样的http吗?
    3. 如果//http使用它而不是http的原因相同?
    4. 如果两者不同,我可以用它来链接我的网站吗?

另外:我不确定,但我认为我似乎有用//name:sub.domaine.com,我错了吗?如果存在,那是什么意思?

编辑:

正如在下面的答案中所解释的,我可以使用//符号来缩短我的链接,但是当我将其用于我的网站时:Chrome将链接更改为:file:///这不是我预期的

protocols http hyperlink web

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

使用 html5 播放 m3u 播放列表

我创建了一个非常简单和基本的 html5 音频播放器,实际上不超过:

<audio src="[url-to-m3u]" controls>
Run Code Online (Sandbox Code Playgroud)

但我面临两个问题,这个简单的音频标签在 Chrome 上运行,但在 Safari 7 中不起作用,第二个是它在我的 iPhone iOS7 和 HTC Android 2.3 上不起作用


播放列表元素是 mp3,内容类型为:audio/mpeg

html audio mobile playlist m3u

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

Swagger Editor OpenAPI 3 上的文件上传在尝试时不显示文件浏览器

我在 OpenAPI 3.0 中使用 Swagger 编辑器。我需要记录一条包含上传图像的路线。尝试“试用”时,我没有让文件浏览器选择要在请求正文中上传的图像,我得到的只是一个带有参数名称和类型的 JSON 字符串。

文件上传“试用”屏幕截图

这是路由的 YAML 描述:

openapi: 3.0.0
...
paths:
  /media/upload/thumbnail:
    post:
      tags:
        - media
        - publications
      security:
        - bearerAuth: []
      summary: upload a kid's publication
      operationId: uploadPublication
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                upload:
                  type: string
                  format: binary
      responses:
        '200':
          description: Successful operation
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: ObjectId of the uploaded file in db (original size)
                    example: 5a6048b3fad06019afe44f24
                  filename:
                    type: string
                    example: myPainting.png
                  thumbnail:
                    type: string
                    description: …
Run Code Online (Sandbox Code Playgroud)

swagger swagger-ui swagger-editor openapi

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

RTL语言uipageviewcontroller动画

我知道这个问题是典型的,并且在论坛上被多次询问,但我仍然无法解决我的问题,所以如果任何机构可以帮助那将是伟大的:)

我正在用阿拉伯语创建一个书籍应用程序,我需要从右到左执行uipageviewcontroller的转换.这就是我要说的.

还有一件事(如果我没有很好地解释我自己)我有这个线程的确切需要:如何更改UIPageViewController分页卷曲动画的方向,但我无法设法他们谈到的解决方案,所以如果有人可以解释我或给我一个链接,我可以有如何做到这将是绰绰有余:)

iphone right-to-left ios5 uipageviewcontroller

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

MPMoviePlayer setCurrentPlaybackTime iOS

我使用MPMoviePlayer播放我的视频,我遇到的问题是当用户按下设备的主页按钮时,我保存了视频的当前位置,而不是当他再次午餐时,我希望他从他离开的地方开始,所以我使用setCurrentPlaybackTime函数,它在iOS 5中完美运行,但在iOS 5.1中,视频从头开始.

有没有人能解决这类问题?

audio objective-c playback mpmovieplayercontroller ios

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

必需的WebGL扩展检测

我正在开发一个WebGL(使用ThreeJs)应用程序,显然,它显示3D模型,我们正在使用一些效果(着色器),希望通过测试来了解用户是否可以运行应用程序,我找到了一种方法检索使用过的浏览器中支持的插件列表.

问题:

我面临的问题是要知道我的应用程序需要什么插件,有没有办法自动检测它们?


更多细节:

有关详细信息,我将指出我需要的示例:

  1. 在Mac OSX Maverix下的MacBook Pro中,应用程序运行正常
  2. 在我的联想笔记本电脑上测试应用程序,在Windows 7下,然后是Windows 8,该应用程序无法正常工作,问题是由Bokeh2 Shader 引起的.

检查支持的WebGL扩展列表我发现,与Mac相比,联想中缺少一些扩展,因此我怎么知道哪些扩展如果丢失将破坏WebGL应用程序.

这是我在mac和lenovo中的扩展名列表.

在我的Mac中:

ANGLE_instanced_arrays

WEBKIT_EXT_texture_filter_anisotropic

OES_element_index_uint

OES_standard_derivatives

OES_texture_float

OES_texture_float_linear

OES_texture_half_float

OES_texture_half_float_linear

OES_vertex_array_object

WEBKIT_WEBGL_compressed_texture_s3tc

WEBKIT_WEBGL_depth_texture

WEBGL_draw_buffers

WEBGL_lose_context

WEBGL_debug_renderer_info

在我的联想:

ANGLE_instanced_arrays

WEBKIT_EXT_texture_filter_anisotropic

OES_element_index_uint

OES_standard_derivatives

OES_texture_float

OES_texture_half_float

OES_texture_half_float_linear

OES_vertex_array_object

WEBKIT_WEBGL_compressed_texture_s3tc

WEBGL_lose_context

WEBGL_debug_renderer_info

联想中缺少的:

OES_texture_float_linear

WEBKIT_WEBGL_depth_texture

WEBGL_draw_buffers

javascript webgl three.js webgl-extensions

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